line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::Natural::Wrappers; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
237
|
use strict; |
|
26
|
|
|
|
|
64
|
|
|
26
|
|
|
|
|
787
|
|
4
|
26
|
|
|
26
|
|
170
|
use warnings; |
|
26
|
|
|
|
|
73
|
|
|
26
|
|
|
|
|
11400
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _add |
9
|
|
|
|
|
|
|
{ |
10
|
2963
|
|
|
2963
|
|
8795
|
my $self = shift; |
11
|
2963
|
|
|
|
|
8293
|
$self->_math(@_); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _subtract |
15
|
|
|
|
|
|
|
{ |
16
|
3443
|
|
|
3443
|
|
11295
|
my $self = shift; |
17
|
3443
|
|
|
|
|
8689
|
$self->_math(@_); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _math |
21
|
|
|
|
|
|
|
{ |
22
|
6406
|
|
|
6406
|
|
10826
|
my $self = shift; |
23
|
6406
|
|
|
|
|
15238
|
my ($unit, $value) = @_; |
24
|
|
|
|
|
|
|
|
25
|
6406
|
|
|
|
|
60344
|
my ($method) = (caller(1))[3] =~ /.+::(.+)$/; |
26
|
6406
|
|
|
|
|
27639
|
$method =~ s/^_//; |
27
|
|
|
|
|
|
|
|
28
|
6406
|
50
|
|
|
|
23247
|
$unit .= 's' unless $unit =~ /s$/; |
29
|
6406
|
|
|
|
|
31826
|
$self->{datetime}->$method($unit => $value); |
30
|
|
|
|
|
|
|
|
31
|
6406
|
|
|
|
|
7177270
|
chop $unit; |
32
|
6406
|
|
|
|
|
36221
|
$self->{modified}{$unit}++; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _add_or_subtract |
36
|
|
|
|
|
|
|
{ |
37
|
3860
|
|
|
3860
|
|
7640
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
3860
|
100
|
|
|
|
11142
|
if (ref $_[0] eq 'HASH') { |
|
|
50
|
|
|
|
|
|
40
|
3724
|
|
|
|
|
6397
|
my %opts = %{$_[0]}; |
|
3724
|
|
|
|
|
14961
|
|
41
|
3724
|
100
|
|
|
|
15414
|
if ($opts{when} > 0) { |
|
|
100
|
|
|
|
|
|
42
|
1671
|
|
|
|
|
6677
|
$self->_add($opts{unit} => $opts{value}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif ($opts{when} < 0) { |
45
|
1351
|
|
|
|
|
4646
|
$self->_subtract($opts{unit} => $opts{value}); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
elsif (@_ == 2) { |
49
|
|
|
|
|
|
|
# Handle additions as expected and also subtractions |
50
|
|
|
|
|
|
|
# as the inverse result of adding a negative number. |
51
|
136
|
|
|
|
|
424
|
$self->_add(@_); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _set |
56
|
|
|
|
|
|
|
{ |
57
|
13353
|
|
|
13353
|
|
25553
|
my $self = shift; |
58
|
13353
|
|
|
|
|
40370
|
my %values = @_; |
59
|
|
|
|
|
|
|
|
60
|
13353
|
|
|
|
|
57527
|
$self->{datetime}->set(%values); |
61
|
|
|
|
|
|
|
|
62
|
13353
|
|
|
|
|
6675345
|
foreach my $unit (keys %values) { |
63
|
27122
|
|
|
|
|
101067
|
$self->{modified}{$unit}++; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
DateTime::Format::Natural::Wrappers - Wrappers for DateTime operations |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Please see the DateTime::Format::Natural documentation. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The C<DateTime::Format::Natural::Wrappers> class provides internal wrappers |
81
|
|
|
|
|
|
|
for DateTime operations. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SEE ALSO |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L<DateTime::Format::Natural> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Steven Schubiger <schubiger@cpan.org> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This program is free software; you may redistribute it and/or |
94
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
See L<http://dev.perl.org/licenses/> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |