line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::end_day; |
2
|
2
|
|
|
2
|
|
990
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
115699
|
|
|
2
|
|
|
|
|
12
|
|
3
|
2
|
|
|
2
|
|
379
|
use Moo; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
414
|
use Catmandu::Util qw(:is :check :array); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
703
|
|
5
|
2
|
|
|
2
|
|
589
|
use DateTime::Format::Strptime; |
|
2
|
|
|
|
|
303131
|
|
|
2
|
|
|
|
|
10
|
|
6
|
2
|
|
|
2
|
|
121
|
use DateTime::TimeZone; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
45
|
|
7
|
2
|
|
|
2
|
|
6
|
use DateTime; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
761
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "0.0131"; |
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
|
5160
|
my($self,$fixer) = @_; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
10
|
my $path = $fixer->split_path($self->path()); |
59
|
|
|
|
|
|
|
my $end_day = $fixer->capture(sub{ |
60
|
2
|
|
|
2
|
|
5467
|
my $skip = shift; |
61
|
2
|
|
|
|
|
13
|
my $d = DateTime->now->set_time_zone($self->time_zone)->truncate(to => "day"); |
62
|
2
|
50
|
|
|
|
870
|
if(is_integer($skip)){ |
63
|
2
|
|
|
|
|
24
|
$d->add(days => $skip); |
64
|
|
|
|
|
|
|
} |
65
|
2
|
|
|
|
|
661
|
$d->add(days => 1,seconds => -1); |
66
|
2
|
|
|
|
|
1215
|
$d; |
67
|
2
|
|
|
|
|
40
|
}); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$fixer->emit_create_path($fixer->var,$path,sub{ |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
2
|
|
122
|
my $var = shift; |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
5
|
my $d = $fixer->generate_var(); |
74
|
2
|
|
|
|
|
60
|
my $p = $fixer->emit_declare_vars($d); |
75
|
2
|
|
|
|
|
27
|
$p .= " $d = ${end_day}->(".$self->add().");"; |
76
|
2
|
|
|
|
|
310
|
$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 |