line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic (Modules::ProhibitMultiplePackages) |
2
|
|
|
|
|
|
|
package DateTime::Infinite; |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
833
|
use strict; |
|
49
|
|
|
|
|
148
|
|
|
49
|
|
|
|
|
1796
|
|
5
|
49
|
|
|
49
|
|
346
|
use warnings; |
|
49
|
|
|
|
|
172
|
|
|
49
|
|
|
|
|
1573
|
|
6
|
49
|
|
|
49
|
|
314
|
use namespace::autoclean; |
|
49
|
|
|
|
|
136
|
|
|
49
|
|
|
|
|
471
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.62'; |
9
|
|
|
|
|
|
|
|
10
|
49
|
|
|
49
|
|
4641
|
use DateTime; |
|
49
|
|
|
|
|
118
|
|
|
49
|
|
|
|
|
1218
|
|
11
|
49
|
|
|
49
|
|
312
|
use DateTime::TimeZone; |
|
49
|
|
|
|
|
128
|
|
|
49
|
|
|
|
|
3060
|
|
12
|
|
|
|
|
|
|
|
13
|
49
|
|
|
49
|
|
403
|
use parent qw(DateTime); |
|
49
|
|
|
|
|
119
|
|
|
49
|
|
|
|
|
354
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
foreach my $m (qw( set set_time_zone truncate )) { |
16
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
17
|
49
|
|
|
49
|
|
4168
|
no strict 'refs'; |
|
49
|
|
|
|
|
1297
|
|
|
49
|
|
|
|
|
24956
|
|
18
|
2
|
|
|
2
|
|
5
|
*{"DateTime::Infinite::$m"} = sub { return $_[0] }; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
1
|
10
|
sub is_finite {0} |
22
|
6
|
|
|
6
|
1
|
44
|
sub is_infinite {1} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
25
|
|
|
|
|
|
|
sub _rd2ymd { |
26
|
98
|
50
|
|
98
|
|
603
|
return $_[2] ? ( $_[1] ) x 7 : ( $_[1] ) x 3; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _seconds_as_components { |
30
|
98
|
|
|
98
|
|
348
|
return ( $_[1] ) x 3; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub ymd { |
34
|
2
|
|
|
2
|
1
|
17
|
return $_[0]->iso8601; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub mdy { |
38
|
2
|
|
|
2
|
1
|
756
|
return $_[0]->iso8601; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub dmy { |
42
|
2
|
|
|
2
|
1
|
782
|
return $_[0]->iso8601; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub hms { |
46
|
4
|
|
|
4
|
1
|
1111
|
return $_[0]->iso8601; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub hour_12 { |
50
|
2
|
|
|
2
|
1
|
812
|
return $_[0]->_infinity_string; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub hour_12_0 { |
54
|
2
|
|
|
2
|
1
|
765
|
return $_[0]->_infinity_string; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub datetime { |
58
|
14
|
|
|
14
|
1
|
774
|
return $_[0]->_infinity_string; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub stringify { |
62
|
2
|
|
|
2
|
1
|
457
|
return $_[0]->_infinity_string; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _infinity_string { |
66
|
20
|
100
|
|
20
|
|
272
|
return $_[0]->{utc_rd_days} == DateTime::INFINITY |
67
|
|
|
|
|
|
|
? DateTime::INFINITY . q{} |
68
|
|
|
|
|
|
|
: DateTime::NEG_INFINITY . q{}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
2
|
|
14
|
sub _week_values { [ $_[0]->{utc_rd_days}, $_[0]->{utc_rd_days} ] } |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
2
|
0
|
833
|
sub STORABLE_freeze {return} |
74
|
0
|
|
|
0
|
0
|
0
|
sub STORABLE_thaw {return} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
package DateTime::Infinite::Future; |
77
|
|
|
|
|
|
|
|
78
|
49
|
|
|
49
|
|
409
|
use strict; |
|
49
|
|
|
|
|
111
|
|
|
49
|
|
|
|
|
1232
|
|
79
|
49
|
|
|
49
|
|
295
|
use warnings; |
|
49
|
|
|
|
|
126
|
|
|
49
|
|
|
|
|
2005
|
|
80
|
|
|
|
|
|
|
|
81
|
49
|
|
|
49
|
|
322
|
use parent qw(DateTime::Infinite); |
|
49
|
|
|
|
|
118
|
|
|
49
|
|
|
|
|
237
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
my $Pos = bless { |
85
|
|
|
|
|
|
|
utc_rd_days => DateTime::INFINITY, |
86
|
|
|
|
|
|
|
utc_rd_secs => DateTime::INFINITY, |
87
|
|
|
|
|
|
|
local_rd_days => DateTime::INFINITY, |
88
|
|
|
|
|
|
|
local_rd_secs => DateTime::INFINITY, |
89
|
|
|
|
|
|
|
rd_nanosecs => DateTime::INFINITY, |
90
|
|
|
|
|
|
|
tz => DateTime::TimeZone->new( name => 'floating' ), |
91
|
|
|
|
|
|
|
locale => FakeLocale->instance, |
92
|
|
|
|
|
|
|
}, |
93
|
|
|
|
|
|
|
__PACKAGE__; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$Pos->_calc_utc_rd; |
96
|
|
|
|
|
|
|
$Pos->_calc_local_rd; |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
4
|
|
533
|
sub new {$Pos} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
package DateTime::Infinite::Past; |
102
|
|
|
|
|
|
|
|
103
|
49
|
|
|
49
|
|
8177
|
use strict; |
|
49
|
|
|
|
|
104
|
|
|
49
|
|
|
|
|
1343
|
|
104
|
49
|
|
|
49
|
|
315
|
use warnings; |
|
49
|
|
|
|
|
142
|
|
|
49
|
|
|
|
|
1592
|
|
105
|
|
|
|
|
|
|
|
106
|
49
|
|
|
49
|
|
302
|
use parent qw(DateTime::Infinite); |
|
49
|
|
|
|
|
165
|
|
|
49
|
|
|
|
|
294
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ |
109
|
|
|
|
|
|
|
my $Neg = bless { |
110
|
|
|
|
|
|
|
utc_rd_days => DateTime::NEG_INFINITY, |
111
|
|
|
|
|
|
|
utc_rd_secs => DateTime::NEG_INFINITY, |
112
|
|
|
|
|
|
|
local_rd_days => DateTime::NEG_INFINITY, |
113
|
|
|
|
|
|
|
local_rd_secs => DateTime::NEG_INFINITY, |
114
|
|
|
|
|
|
|
rd_nanosecs => DateTime::NEG_INFINITY, |
115
|
|
|
|
|
|
|
tz => DateTime::TimeZone->new( name => 'floating' ), |
116
|
|
|
|
|
|
|
locale => FakeLocale->instance, |
117
|
|
|
|
|
|
|
}, |
118
|
|
|
|
|
|
|
__PACKAGE__; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$Neg->_calc_utc_rd; |
121
|
|
|
|
|
|
|
$Neg->_calc_local_rd; |
122
|
|
|
|
|
|
|
|
123
|
4
|
|
|
4
|
|
716
|
sub new {$Neg} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package # hide from PAUSE |
127
|
|
|
|
|
|
|
FakeLocale; |
128
|
|
|
|
|
|
|
|
129
|
49
|
|
|
49
|
|
7698
|
use strict; |
|
49
|
|
|
|
|
120
|
|
|
49
|
|
|
|
|
1252
|
|
130
|
49
|
|
|
49
|
|
273
|
use warnings; |
|
49
|
|
|
|
|
149
|
|
|
49
|
|
|
|
|
1581
|
|
131
|
|
|
|
|
|
|
|
132
|
49
|
|
|
49
|
|
345
|
use DateTime::Locale; |
|
49
|
|
|
|
|
97
|
|
|
49
|
|
|
|
|
8338
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $Instance; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub instance { |
137
|
98
|
|
100
|
98
|
|
10028
|
return $Instance ||= bless { locale => DateTime::Locale->load('en_US') }, |
138
|
|
|
|
|
|
|
__PACKAGE__; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub id { |
142
|
0
|
|
|
0
|
|
0
|
return 'infinite'; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub language_id { |
146
|
0
|
|
|
0
|
|
0
|
return 'infinite'; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub name { |
150
|
1
|
|
|
1
|
|
5
|
'Fake locale for Infinite DateTime objects'; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub language { |
154
|
0
|
|
|
0
|
|
0
|
'Fake locale for Infinite DateTime objects'; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
my @methods = qw( |
158
|
|
|
|
|
|
|
script_id |
159
|
|
|
|
|
|
|
territory_id |
160
|
|
|
|
|
|
|
variant_id |
161
|
|
|
|
|
|
|
script |
162
|
|
|
|
|
|
|
territory |
163
|
|
|
|
|
|
|
variant |
164
|
|
|
|
|
|
|
native_name |
165
|
|
|
|
|
|
|
native_language |
166
|
|
|
|
|
|
|
native_script |
167
|
|
|
|
|
|
|
native_territory |
168
|
|
|
|
|
|
|
native_variant |
169
|
|
|
|
|
|
|
); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
for my $meth (@methods) { |
172
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
173
|
49
|
|
|
49
|
|
372
|
no strict 'refs'; |
|
49
|
|
|
|
|
134
|
|
|
49
|
|
|
|
|
12663
|
|
174
|
0
|
|
|
0
|
|
0
|
*{$meth} = sub {undef}; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Totally arbitrary |
178
|
|
|
|
|
|
|
sub first_day_of_week { |
179
|
0
|
|
|
0
|
|
0
|
return 1; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub prefers_24_hour_time { |
183
|
0
|
|
|
0
|
|
0
|
return 0; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
our $AUTOLOAD; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
## no critic (ClassHierarchies::ProhibitAutoloading) |
189
|
|
|
|
|
|
|
sub AUTOLOAD { |
190
|
5
|
|
|
5
|
|
1300
|
my $self = shift; |
191
|
|
|
|
|
|
|
|
192
|
5
|
|
|
|
|
40
|
my ($meth) = $AUTOLOAD =~ /::(\w+)$/; |
193
|
|
|
|
|
|
|
|
194
|
5
|
100
|
100
|
|
|
36
|
if ( $meth =~ /format/ && $meth !~ /^(?:day|month|quarter)/ ) { |
195
|
1
|
|
|
|
|
11
|
return $self->{locale}->$meth(@_); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
4
|
|
|
|
|
43
|
return []; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# ABSTRACT: Infinite past and future DateTime objects |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
__END__ |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=pod |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=encoding UTF-8 |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 NAME |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
DateTime::Infinite - Infinite past and future DateTime objects |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 VERSION |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
version 1.62 |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 SYNOPSIS |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
my $future = DateTime::Infinite::Future->new; |
222
|
|
|
|
|
|
|
my $past = DateTime::Infinite::Past->new; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 DESCRIPTION |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This module provides two L<DateTime> subclasses, C<DateTime::Infinite::Future> |
227
|
|
|
|
|
|
|
and C<DateTime::Infinite::Past>. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
The objects are always in the "floating" timezone, and this cannot be changed. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 METHODS |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
The only constructor for these two classes is the C<new> method, as shown in |
234
|
|
|
|
|
|
|
the L</SYNOPSIS>. This method takes no parameters. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
All "get" methods in this module simply return infinity, positive or negative. |
237
|
|
|
|
|
|
|
If the method is expected to return a string, it returns the string |
238
|
|
|
|
|
|
|
representation of positive or negative infinity used by your system. For |
239
|
|
|
|
|
|
|
example, on my system calling C<< $dt->year >>> returns a number which when |
240
|
|
|
|
|
|
|
printed appears either "Inf" or "-Inf". |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This also applies to methods that are compound stringifications, which return |
243
|
|
|
|
|
|
|
the same strings even for things like C<< $dt->ymd >> or C<< $dt->iso8601 >> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
The object is not mutable, so the C<< $dt->set >>, C<< $dt->set_time_zone >>, |
246
|
|
|
|
|
|
|
and C<< $dt->truncate >> methods are all do-nothing methods that simply return |
247
|
|
|
|
|
|
|
the object they are called with. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Obviously, the C<< $dt->is_finite >> method returns false and the C<< |
250
|
|
|
|
|
|
|
$dt->is_infinite >> method returns true. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SEE ALSO |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
datetime@perl.org mailing list |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 BUGS |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
There seem to be lots of problems when dealing with infinite numbers on Win32. |
259
|
|
|
|
|
|
|
This may be a problem with this code, Perl, or Win32's IEEE math |
260
|
|
|
|
|
|
|
implementation. Either way, the module may not be well-behaved on Win32 |
261
|
|
|
|
|
|
|
operating systems. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/DateTime.pm/issues>. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
There is a mailing list available for users of this distribution, |
266
|
|
|
|
|
|
|
L<mailto:datetime@perl.org>. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 SOURCE |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
The source code repository for DateTime can be found at L<https://github.com/houseabsolute/DateTime.pm>. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 AUTHOR |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
This software is Copyright (c) 2003 - 2023 by Dave Rolsky. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
This is free software, licensed under: |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
The full text of the license can be found in the |
285
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=cut |