line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::end_day; |
2
|
2
|
|
|
2
|
|
726
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
108738
|
|
|
2
|
|
|
|
|
10
|
|
3
|
2
|
|
|
2
|
|
328
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
406
|
use Catmandu::Util qw(:is :check :array); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
764
|
|
5
|
2
|
|
|
2
|
|
513
|
use DateTime::Format::Strptime; |
|
2
|
|
|
|
|
77011
|
|
|
2
|
|
|
|
|
12
|
|
6
|
2
|
|
|
2
|
|
135
|
use DateTime::TimeZone; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
34
|
|
7
|
2
|
|
|
2
|
|
19
|
use DateTime; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
834
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "0.0130"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Fix::Base'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => ( |
14
|
|
|
|
|
|
|
is => 'ro' , |
15
|
|
|
|
|
|
|
required => 1 |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
has add => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => sub { check_integer($_[0]); }, |
20
|
|
|
|
|
|
|
required => 0, |
21
|
|
|
|
|
|
|
lazy => 1, |
22
|
|
|
|
|
|
|
default => sub { 0; } |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
has time_zone => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
isa => sub { |
28
|
|
|
|
|
|
|
check_string($_[0]); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
default => sub { |
31
|
|
|
|
|
|
|
"UTC" |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
has pattern => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
isa => sub { |
38
|
|
|
|
|
|
|
check_string($_[0]); |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
default => sub { |
41
|
|
|
|
|
|
|
"%FT%T.%NZ" |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
around BUILDARGS => sub { |
46
|
|
|
|
|
|
|
my($orig,$class,$path,%args) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$orig->($class, |
49
|
|
|
|
|
|
|
path => $path, |
50
|
|
|
|
|
|
|
%args |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub emit { |
56
|
2
|
|
|
2
|
0
|
4748
|
my($self,$fixer) = @_; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
8
|
my $path = $fixer->split_path($self->path()); |
59
|
|
|
|
|
|
|
my $end_day = $fixer->capture(sub{ |
60
|
2
|
|
|
2
|
|
5456
|
my $skip = shift; |
61
|
2
|
|
|
|
|
12
|
my $d = DateTime->now->set_time_zone($self->time_zone)->truncate(to => "day"); |
62
|
2
|
50
|
|
|
|
764
|
if(is_integer($skip)){ |
63
|
2
|
|
|
|
|
22
|
$d->add(days => $skip); |
64
|
|
|
|
|
|
|
} |
65
|
2
|
|
|
|
|
426
|
$d->add(days => 1,seconds => -1); |
66
|
2
|
|
|
|
|
717
|
$d; |
67
|
2
|
|
|
|
|
29
|
}); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$fixer->emit_create_path($fixer->var,$path,sub{ |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
2
|
|
121
|
my $var = shift; |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
4
|
my $d = $fixer->generate_var(); |
74
|
2
|
|
|
|
|
60
|
my $p = $fixer->emit_declare_vars($d); |
75
|
2
|
|
|
|
|
25
|
$p .= " $d = ${end_day}->(".$self->add().");"; |
76
|
2
|
|
|
|
|
303
|
$p .= " ${var} = DateTime::Format::Strptime::strftime('".$self->pattern()."',$d);"; |
77
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
5
|
$p; |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
120
|
}); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Catmandu::Fix::end_day - Catmandu Fix retrieving date string for end of the current day |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SYNOPSIS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#get end of the day in the time zone Europe/Brussels |
94
|
|
|
|
|
|
|
end_day('end_day','pattern' => '%Y-%m-%dT%H:%M:SZ','time_zone' => 'Europe/Brussels') |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#get end of the day tomorrow in the time zone Europe/Brussels |
97
|
|
|
|
|
|
|
end_day('end_day','pattern' => '%Y-%m-%dT%H:%M:SZ','time_zone' => 'Europe/Brussels', 'add' => 1) |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Nicolas Franck, C<< <nicolas.franck at ugent.be> >> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<Catmandu::Fix> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |