1 package DateTime::Infinite;
9 use DateTime::TimeZone;
11 use base qw(DateTime);
13 foreach my $m ( qw( set set_time_zone truncate ) )
16 *{"DateTime::Infinite::$m"} =
25 return $_[2] ? ($_[1]) x 7 : ($_[1]) x 3;
28 sub _seconds_as_components
33 sub _stringify { ( $_[0]->{utc_rd_days} == DateTime::INFINITY
34 ? DateTime::INFINITY . ''
35 : DateTime::NEG_INFINITY . ''
38 sub STORABLE_freeze { return }
39 sub STORABLE_thaw { return }
41 package DateTime::Infinite::Future;
43 use base qw(DateTime::Infinite);
46 my $Pos = bless { utc_rd_days => DateTime::INFINITY,
47 utc_rd_secs => DateTime::INFINITY,
48 local_rd_days => DateTime::INFINITY,
49 local_rd_secs => DateTime::INFINITY,
50 rd_nanosecs => DateTime::INFINITY,
51 tz => DateTime::TimeZone->new( name => 'floating' ),
60 package DateTime::Infinite::Past;
62 use base qw(DateTime::Infinite);
65 my $Neg = bless { utc_rd_days => DateTime::NEG_INFINITY,
66 utc_rd_secs => DateTime::NEG_INFINITY,
67 local_rd_days => DateTime::NEG_INFINITY,
68 local_rd_secs => DateTime::NEG_INFINITY,
69 rd_nanosecs => DateTime::NEG_INFINITY,
70 tz => DateTime::TimeZone->new( name => 'floating' ),
86 DateTime::Infinite - Infinite past and future DateTime objects
90 my $future = DateTime::Infinite::Future->new;
91 my $past = DateTime::Infinite::Past->new;
95 This module provides two L<DateTime.pm|DateTime> subclasses,
96 C<DateTime::Infinite::Future> and C<DateTime::Infinite::Past>.
98 The objects are in the "floating" timezone, and this cannot be
103 There seem to be lots of problems when dealing with infinite numbers
104 on Win32. This may be a problem with this code, Perl, or Win32's IEEE
105 math implementation. Either way, the module may not be well-behaved
106 on Win32 operating systems.
110 The only constructor for these two classes is the C<new()> method, as
111 shown in the L<SYNOPSIS|/SYNOPSIS>. This method takes no parameters.
113 All "get" methods in this module simply return infinity, positive or
114 negative. If the method is expected to return a string, it return the
115 string representation of positive or negative infinity used by your
116 system. For example, on my system calling C<year()> returns a number
117 which when printed appears either "inf" or "-inf".
119 The object is not mutable, so the C<set()>, C<set_time_zone()>, and
120 C<truncate()> methods are all do-nothing methods that simply return
121 the object they are called with.
123 Obviously, the C<is_finite()> method returns false and the
124 C<is_infinite()> method returns true.
128 Dave Rolsky <autarch@urth.org>
132 Copyright (c) 2003-2009 David Rolsky. All rights reserved. This
133 program is free software; you can redistribute it and/or modify it
134 under the same terms as Perl itself.
136 The full text of the license can be found in the LICENSE file included
141 datetime@perl.org mailing list
143 http://datetime.perl.org/