line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::LazyInit; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
225865
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use DateTime; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
17
|
|
7
|
1
|
|
|
1
|
|
4
|
use vars qw/$AUTOLOAD $VERSION $VERBOSE/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
415
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# DEVELOPER NOTE: |
11
|
|
|
|
|
|
|
# We have to force these methods to inflate as the overloads were only forcing |
12
|
|
|
|
|
|
|
# $_[0] to inflate properly. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use overload ( |
15
|
|
|
|
|
|
|
'fallback' => 1, |
16
|
|
|
|
|
|
|
'<=>' => sub { |
17
|
0
|
0
|
|
0
|
|
0
|
$_[0]->inflate() if ref($_[0]) =~ /^DateTime::LazyInit/; |
18
|
0
|
0
|
|
|
|
0
|
$_[1]->inflate() if ref($_[1]) =~ /^DateTime::LazyInit/; |
19
|
0
|
|
|
|
|
0
|
shift->_compare_overload(@_); |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
'cmp' => sub { |
22
|
0
|
0
|
|
0
|
|
0
|
$_[0]->inflate() if ref($_[0]) =~ /^DateTime::LazyInit/; |
23
|
0
|
0
|
|
|
|
0
|
$_[1]->inflate() if ref($_[1]) =~ /^DateTime::LazyInit/; |
24
|
0
|
|
|
|
|
0
|
shift->_compare_overload(@_); |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
'""' => sub { |
27
|
1
|
50
|
|
1
|
|
1091
|
$_[0]->inflate() if ref($_[0]) =~ /^DateTime::LazyInit/; |
28
|
1
|
50
|
|
|
|
5
|
$_[1]->inflate() if ref($_[1]) =~ /^DateTime::LazyInit/; |
29
|
1
|
|
|
|
|
6
|
shift->_stringify(@_); |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
'-' => sub { |
32
|
0
|
0
|
|
0
|
|
0
|
$_[0]->inflate() if ref($_[0]) =~ /^DateTime::LazyInit/; |
33
|
0
|
0
|
|
|
|
0
|
$_[1]->inflate() if ref($_[1]) =~ /^DateTime::LazyInit/; |
34
|
0
|
|
|
|
|
0
|
shift->_subtract_overload(@_) |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
'+' => sub { |
37
|
0
|
0
|
|
0
|
|
0
|
$_[0]->inflate() if ref($_[0]) =~ /^DateTime::LazyInit/; |
38
|
0
|
0
|
|
|
|
0
|
$_[1]->inflate() if ref($_[1]) =~ /^DateTime::LazyInit/; |
39
|
0
|
|
|
|
|
0
|
shift->_add_overload(@_) |
40
|
|
|
|
|
|
|
}, |
41
|
1
|
|
|
1
|
|
6
|
); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$VERSION = '1.0200'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$VERBOSE = 0; # Set to non-0 to 'warn' every time an object inflates |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
49
|
5
|
|
|
5
|
1
|
24
|
my $class = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# NO VALIDATION |
52
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
53
|
5
|
|
|
|
|
23
|
my %args = @_; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
37
|
return bless \%args, 'DateTime::LazyInit::Constructor_new'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_new; |
60
|
1
|
|
|
1
|
|
181
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
61
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub from_epoch { |
65
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# NO VALIDATION |
68
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
69
|
0
|
|
|
|
|
0
|
my %args = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
return bless \%args, 'DateTime::LazyInit::Constructor_from_epoch'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
{ |
75
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_from_epoch; |
76
|
1
|
|
|
1
|
|
4
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
104
|
|
77
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub now { |
81
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# NO VALIDATION |
84
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
85
|
0
|
|
|
|
|
0
|
my %args = @_; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
return bless \%args, 'DateTime::LazyInit::Constructor_now'; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_now; |
92
|
1
|
|
|
1
|
|
6
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
126
|
|
93
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub today { |
97
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# NO VALIDATION |
100
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
101
|
0
|
|
|
|
|
0
|
my %args = @_; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
return bless \%args, 'DateTime::LazyInit::Constructor_today'; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_today; |
108
|
1
|
|
|
1
|
|
4
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
84
|
|
109
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub from_object { |
113
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# NO VALIDATION |
116
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
117
|
0
|
|
|
|
|
0
|
my %args = @_; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
return bless \%args, 'DateTime::LazyInit::Constructor_from_object'; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
{ |
123
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_from_object; |
124
|
1
|
|
|
1
|
|
4
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
77
|
|
125
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub last_day_of_month { |
129
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# NO VALIDATION |
132
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
133
|
0
|
|
|
|
|
0
|
my %args = @_; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
return bless \%args, 'DateTime::LazyInit::Constructor_last_day_of_month'; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
{ |
139
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_last_day_of_month; |
140
|
1
|
|
|
1
|
|
4
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
91
|
|
141
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub from_day_of_year { |
145
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# NO VALIDATION |
148
|
|
|
|
|
|
|
# We'll accept your grandmother if you pass her to us. |
149
|
0
|
|
|
|
|
0
|
my %args = @_; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
0
|
return bless \%args, 'DateTime::LazyInit::Constructor_from_day_of_year'; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
{ |
155
|
|
|
|
|
|
|
package DateTime::LazyInit::Constructor_from_day_of_year; |
156
|
1
|
|
|
1
|
|
4
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
790
|
|
157
|
|
|
|
|
|
|
@ISA = qw/DateTime::LazyInit/; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub AUTOLOAD { |
162
|
|
|
|
|
|
|
|
163
|
1
|
|
|
1
|
|
2
|
my $attr = $AUTOLOAD; |
164
|
1
|
|
|
|
|
17
|
$attr =~ s/.*:://; |
165
|
1
|
50
|
|
|
|
6
|
return unless $attr =~ /[^A-Z]/; # skip DESTROY and all-cap methods |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Anything else, we need to inflate into a DateTime object. |
168
|
1
|
|
|
|
|
8
|
return shift->inflate($attr, @_); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# Simple set and get for year |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub set_year { |
174
|
1
|
|
|
1
|
0
|
4
|
$_[0]->{year} = $_[1]; |
175
|
1
|
|
|
|
|
3
|
return $_[0]; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub year { |
179
|
2
|
50
|
|
2
|
1
|
13
|
return $_[0]->{year} if $_[0]->{year}; |
180
|
0
|
|
|
|
|
0
|
return 0; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# Simple set and get for month |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub set_month { |
188
|
1
|
|
|
1
|
0
|
286
|
$_[0]->{month} = $_[1]; |
189
|
1
|
|
|
|
|
2
|
return $_[0]; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub month { |
193
|
4
|
50
|
|
4
|
1
|
26
|
return $_[0]->{month} if $_[0]->{month}; |
194
|
0
|
|
|
|
|
0
|
return 1; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# Simple set and get for day |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub set_day { |
202
|
1
|
|
|
1
|
0
|
301
|
$_[0]->{day} = $_[1]; |
203
|
1
|
|
|
|
|
3
|
return $_[0]; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub day { |
207
|
5
|
50
|
|
5
|
1
|
35
|
return $_[0]->{day} if $_[0]->{day}; |
208
|
0
|
|
|
|
|
0
|
return 1; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Simple set and get for hour |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub set_hour { |
216
|
1
|
|
|
1
|
0
|
325
|
$_[0]->{hour} = $_[1]; |
217
|
1
|
|
|
|
|
4
|
return $_[0]; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub hour { |
221
|
3
|
100
|
|
3
|
1
|
519
|
return $_[0]->{hour} if $_[0]->{hour}; |
222
|
1
|
|
|
|
|
5
|
return 0; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# Simple set and get for minute |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub set_minute { |
230
|
1
|
|
|
1
|
0
|
352
|
$_[0]->{minute} = $_[1]; |
231
|
1
|
|
|
|
|
3
|
return $_[0]; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub minute { |
235
|
2
|
50
|
|
2
|
1
|
11
|
return $_[0]->{minute} if $_[0]->{minute}; |
236
|
0
|
|
|
|
|
0
|
return 0; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# Simple set and get for second |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub set_second { |
244
|
1
|
|
|
1
|
0
|
241
|
$_[0]->{second} = $_[1]; |
245
|
1
|
|
|
|
|
3
|
return $_[0]; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub second { |
249
|
2
|
50
|
|
2
|
1
|
10
|
return $_[0]->{second} if $_[0]->{second}; |
250
|
0
|
|
|
|
|
0
|
return 0; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# Simple set and get for nanosecond |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub set_nanosecond { |
258
|
1
|
|
|
1
|
0
|
257
|
$_[0]->{nanosecond} = $_[1]; |
259
|
1
|
|
|
|
|
3
|
return $_[0]; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub nanosecond { |
263
|
2
|
50
|
|
2
|
1
|
12
|
return $_[0]->{nanosecond} if $_[0]->{nanosecond}; |
264
|
0
|
|
|
|
|
0
|
return 0; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# Simple set for locale |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub set_locale { |
272
|
1
|
|
|
1
|
0
|
315
|
$_[0]->{locale} = $_[1]; |
273
|
1
|
|
|
|
|
3
|
return $_[0]; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# Simple set for time_zone |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub set_time_zone { |
281
|
1
|
|
|
1
|
0
|
341
|
$_[0]->{time_zone} = $_[1]; |
282
|
1
|
|
|
|
|
4
|
return $_[0]; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub set { |
288
|
9
|
|
|
9
|
0
|
704
|
my $self = shift; |
289
|
9
|
|
|
|
|
21
|
my %attr = @_; |
290
|
9
|
|
|
|
|
26
|
foreach (keys %attr) { |
291
|
10
|
|
|
|
|
26
|
$self->{$_} = $attr{$_} |
292
|
|
|
|
|
|
|
} |
293
|
9
|
|
|
|
|
24
|
return $self; |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub clone { |
299
|
4
|
|
|
4
|
0
|
276
|
return ref($_[0])->new( %{$_[0]} ); |
|
4
|
|
|
|
|
39
|
|
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
# These methods inflate, they're just here so that UNVERSAL::can will work |
305
|
|
|
|
|
|
|
# if you find any other methods that need to be here, please email |
306
|
|
|
|
|
|
|
# the author or the mailing list |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub utc_rd_values { |
309
|
0
|
|
|
0
|
0
|
0
|
shift->inflate('utc_rd_values',@_); |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
# This is the inflator |
314
|
|
|
|
|
|
|
sub inflate { |
315
|
2
|
|
|
2
|
1
|
11
|
(my $constructor) = ref($_[0]) =~ /Constructor_(.+)$/; |
316
|
2
|
|
|
|
|
3
|
$_[0] = bless \%{DateTime->$constructor(%{$_[0]})}, 'DateTime'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
19
|
|
317
|
2
|
50
|
|
|
|
2750
|
warn("Inflating $_[0].\n") if $VERBOSE; |
318
|
|
|
|
|
|
|
# And call the method on that |
319
|
2
|
|
|
|
|
4
|
my $self = shift; |
320
|
2
|
|
|
|
|
3
|
my ($method) = shift; |
321
|
2
|
100
|
|
|
|
9
|
return ($method) ? $self->$method( @_ ) : $self; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
1; |
326
|
|
|
|
|
|
|
__END__ |