line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::Natural::Wrappers; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
228
|
use strict; |
|
26
|
|
|
|
|
82
|
|
|
26
|
|
|
|
|
773
|
|
4
|
26
|
|
|
26
|
|
152
|
use warnings; |
|
26
|
|
|
|
|
78
|
|
|
26
|
|
|
|
|
10783
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _add |
9
|
|
|
|
|
|
|
{ |
10
|
2938
|
|
|
2938
|
|
7941
|
my $self = shift; |
11
|
2938
|
|
|
|
|
8543
|
$self->_math(@_); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _subtract |
15
|
|
|
|
|
|
|
{ |
16
|
3468
|
|
|
3468
|
|
11244
|
my $self = shift; |
17
|
3468
|
|
|
|
|
9014
|
$self->_math(@_); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _math |
21
|
|
|
|
|
|
|
{ |
22
|
6406
|
|
|
6406
|
|
10636
|
my $self = shift; |
23
|
6406
|
|
|
|
|
13884
|
my ($unit, $value) = @_; |
24
|
|
|
|
|
|
|
|
25
|
6406
|
|
|
|
|
59789
|
my ($method) = (caller(1))[3] =~ /.+::(.+)$/; |
26
|
6406
|
|
|
|
|
28409
|
$method =~ s/^_//; |
27
|
|
|
|
|
|
|
|
28
|
6406
|
50
|
|
|
|
22701
|
$unit .= 's' unless $unit =~ /s$/; |
29
|
6406
|
|
|
|
|
30910
|
$self->{datetime}->$method($unit => $value); |
30
|
|
|
|
|
|
|
|
31
|
6406
|
|
|
|
|
7040859
|
chop $unit; |
32
|
6406
|
|
|
|
|
35786
|
$self->{modified}{$unit}++; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _add_or_subtract |
36
|
|
|
|
|
|
|
{ |
37
|
3860
|
|
|
3860
|
|
7354
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
3860
|
100
|
|
|
|
10101
|
if (ref $_[0] eq 'HASH') { |
|
|
50
|
|
|
|
|
|
40
|
3724
|
|
|
|
|
6692
|
my %opts = %{$_[0]}; |
|
3724
|
|
|
|
|
14299
|
|
41
|
3724
|
100
|
|
|
|
14053
|
if ($opts{when} > 0) { |
|
|
100
|
|
|
|
|
|
42
|
1671
|
|
|
|
|
5843
|
$self->_add($opts{unit} => $opts{value}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif ($opts{when} < 0) { |
45
|
1351
|
|
|
|
|
4455
|
$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
|
|
|
|
|
427
|
$self->_add(@_); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _set |
56
|
|
|
|
|
|
|
{ |
57
|
13353
|
|
|
13353
|
|
24250
|
my $self = shift; |
58
|
13353
|
|
|
|
|
39640
|
my %values = @_; |
59
|
|
|
|
|
|
|
|
60
|
13353
|
|
|
|
|
55064
|
$self->{datetime}->set(%values); |
61
|
|
|
|
|
|
|
|
62
|
13353
|
|
|
|
|
6569957
|
foreach my $unit (keys %values) { |
63
|
27122
|
|
|
|
|
97942
|
$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 |