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