line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Functions; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
125886
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
6
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
67
|
use DateTime (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw( |
13
|
|
|
|
|
|
|
datetime from_epoch now today from_object |
14
|
|
|
|
|
|
|
last_day_of_month from_day_of_year default_locale |
15
|
|
|
|
|
|
|
compare compare_ignore_floating duration |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=encoding utf8 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
DateTime::Functions - Procedural interface to DateTime functions |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This document describes version 0.10 of DateTime::Functions, released |
27
|
|
|
|
|
|
|
December 9, 2010 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use DateTime::Functions; |
32
|
|
|
|
|
|
|
print today->year; |
33
|
|
|
|
|
|
|
print now->strftime("%Y-%m-%d %H:%M:%S"); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This module simply exports all class methods of L into the |
38
|
|
|
|
|
|
|
caller's namespace. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Unless otherwise noted, all methods correspond to the same-named class |
43
|
|
|
|
|
|
|
method in L. Please see L for which parameters are |
44
|
|
|
|
|
|
|
supported. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 Constructors |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
All constructors can die when invalid parameters are given. They all |
49
|
|
|
|
|
|
|
return C objects, except for C which returns |
50
|
|
|
|
|
|
|
a C object. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 4 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * datetime( ... ) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Equivalent to C<< DateTime->new( ... ) >>. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * duration( ... ) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Equivalent to C<< DateTime::Duration->new( ... ) >>. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * from_epoch( epoch => $epoch, ... ) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * now( ... ) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * today( ... ) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * from_object( object => $object, ... ) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * last_day_of_month( ... ) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * from_day_of_year( ... ) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 Utility Functions |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over 4 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * default_locale( $locale ) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Equivalent to C<< DateTime->DefaultLocale( $locale ) >>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * compare |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * compare_ignore_floating |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
foreach my $func (@EXPORT) { |
93
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
143
|
|
94
|
|
|
|
|
|
|
my $method = $func; |
95
|
|
|
|
|
|
|
next if $func eq 'duration'; |
96
|
|
|
|
|
|
|
$method = 'new' if $func eq 'datetime'; |
97
|
|
|
|
|
|
|
$method = 'DefaultLocale' if $func eq 'default_locale'; |
98
|
2
|
|
|
2
|
|
1257
|
*$func = sub { DateTime->can($method)->('DateTime', @_) }; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub duration { |
102
|
0
|
|
|
0
|
1
|
|
require DateTime::Duration; |
103
|
0
|
|
|
|
|
|
return DateTime::Duration->new(@_); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SEE ALSO |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHORS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
唐鳳 Ecpan@audreyt.orgE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
唐鳳 has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This work is published from Taiwan. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |