line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::DateTime; |
2
|
1
|
|
|
1
|
|
43621
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
54
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
1603
|
use DateTime; |
|
1
|
|
|
|
|
235627
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
1224
|
use DateTime::Format::Strptime; |
|
1
|
|
|
|
|
8044
|
|
|
1
|
|
|
|
|
68
|
|
6
|
1
|
|
|
1
|
|
1142
|
use Template::Plugin; |
|
1
|
|
|
|
|
5680
|
|
|
1
|
|
|
|
|
34
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
9
|
use vars qw($AUTHORITY $VERSION @ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
128
|
|
9
|
|
|
|
|
|
|
BEGIN |
10
|
|
|
|
|
|
|
{ |
11
|
1
|
|
|
1
|
|
2
|
$VERSION = '0.06002'; |
12
|
1
|
|
|
|
|
2
|
$AUTHORITY = 'cpan:DMAKI'; |
13
|
1
|
|
|
|
|
243
|
@ISA = (qw(Template::Plugin)); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new |
17
|
|
|
|
|
|
|
{ |
18
|
10
|
|
|
10
|
1
|
182990
|
my $class = shift; |
19
|
10
|
|
|
|
|
21
|
my $context = shift; |
20
|
|
|
|
|
|
|
|
21
|
10
|
50
|
|
|
|
42
|
my %args = ref($_[0]) eq 'HASH' ? %{$_[0]} : (); |
|
10
|
|
|
|
|
46
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# boolean args: now, today, last_day_of_month |
24
|
10
|
|
|
|
|
29
|
foreach my $arg (qw(now today last_day_of_month)){ |
25
|
23
|
100
|
|
|
|
135
|
if (delete $args{$arg}) { |
26
|
5
|
|
|
|
|
39
|
return DateTime->$arg(%args); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# args that require to proxy the parameter: from_epoch, from_object |
31
|
5
|
100
|
|
|
|
45
|
if (my $epoch = delete $args{from_epoch}) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
1
|
|
|
|
|
6
|
return DateTime->from_epoch(epoch => $epoch, %args); |
33
|
|
|
|
|
|
|
} elsif (my $object = delete $args{from_object}) { |
34
|
1
|
|
|
|
|
53
|
return DateTime->from_object(object => $object, %args); |
35
|
|
|
|
|
|
|
} elsif (my $timestr = delete $args{from_string}) { |
36
|
1
|
|
50
|
|
|
5
|
my $pattern = delete $args{pattern} || '%Y-%m-%d %H:%M:%S'; |
37
|
1
|
|
|
|
|
16
|
my $parser = DateTime::Format::Strptime->new( pattern => $pattern, %args); |
38
|
1
|
|
|
|
|
635
|
my $dt = $parser->parse_datetime($timestr); |
39
|
1
|
|
|
|
|
988
|
return $dt; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# none of the above, use regular call to new. |
43
|
2
|
|
|
|
|
20
|
return DateTime->new(%args); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |