line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package autobox::DateTime::Duration; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
26233
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
114
|
|
4
|
3
|
|
|
3
|
|
41
|
use 5.8.1; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
247
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
915
|
use autobox; |
|
3
|
|
|
|
|
10932
|
|
|
3
|
|
|
|
|
31
|
|
8
|
3
|
|
|
3
|
|
2433
|
use DateTime; |
|
3
|
|
|
|
|
241285
|
|
|
3
|
|
|
|
|
85
|
|
9
|
3
|
|
|
3
|
|
44
|
use DateTime::Duration; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
127
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
for my $accessor (qw( day hour minute month second week year )) { |
12
|
3
|
|
|
3
|
|
59
|
no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1042
|
|
13
|
|
|
|
|
|
|
my $plural = $accessor . "s"; |
14
|
|
|
|
|
|
|
*{"SCALAR::$accessor"} = *{"SCALAR::$plural"} = sub { |
15
|
15
|
|
|
15
|
|
6447
|
DateTime::Duration->new($plural => $_[0]); |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub SCALAR::fortnight { |
20
|
1
|
|
|
1
|
|
401
|
DateTime::Duration->new(weeks => 2 * $_[0]); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
*SCALAR::fortnights = \&SCALAR::fortnight; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub DateTime::Duration::ago { |
26
|
2
|
|
|
2
|
0
|
243
|
my $duration = shift; |
27
|
2
|
50
|
|
|
|
64
|
my $dt = $_[0] ? $_[0]->clone : DateTime->now; |
28
|
2
|
|
|
|
|
170
|
$dt->subtract_duration($duration); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
*DateTime::Duration::until = \&DateTime::Duration::ago; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub DateTime::Duration::from_now { |
34
|
2
|
|
|
2
|
0
|
187
|
my $duration = shift; |
35
|
2
|
50
|
|
|
|
12
|
my $dt = $_[0] ? $_[0]->clone : DateTime->now; |
36
|
2
|
|
|
|
|
146
|
$dt->add_duration($duration); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
*DateTime::Duration::since = \&DateTime::Duration::from_now; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |