Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / i486-linux-gnu-thread-multi / DateTime / Infinite.pm
CommitLineData
3fea05b9 1package DateTime::Infinite;
2
3use strict;
4use warnings;
5
6our $VERSION = '0.53';
7
8use DateTime;
9use DateTime::TimeZone;
10
11use base qw(DateTime);
12
13foreach my $m ( qw( set set_time_zone truncate ) )
14{
15 no strict 'refs';
16 *{"DateTime::Infinite::$m"} =
17 sub { return $_[0] };
18}
19
20sub is_finite { 0 }
21sub is_infinite { 1 }
22
23sub _rd2ymd
24{
25 return $_[2] ? ($_[1]) x 7 : ($_[1]) x 3;
26}
27
28sub _seconds_as_components
29{
30 return ($_[1]) x 3;
31}
32
33sub _stringify { ( $_[0]->{utc_rd_days} == DateTime::INFINITY
34 ? DateTime::INFINITY . ''
35 : DateTime::NEG_INFINITY . ''
36 ) }
37
38sub STORABLE_freeze { return }
39sub STORABLE_thaw { return }
40
41package DateTime::Infinite::Future;
42
43use base qw(DateTime::Infinite);
44
45{
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' ),
52 }, __PACKAGE__;
53
54 $Pos->_calc_utc_rd;
55 $Pos->_calc_local_rd;
56
57 sub new { $Pos }
58}
59
60package DateTime::Infinite::Past;
61
62use base qw(DateTime::Infinite);
63
64{
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' ),
71 }, __PACKAGE__;
72
73 $Neg->_calc_utc_rd;
74 $Neg->_calc_local_rd;
75
76 sub new { $Neg }
77}
78
79
801;
81
82__END__
83
84=head1 NAME
85
86DateTime::Infinite - Infinite past and future DateTime objects
87
88=head1 SYNOPSIS
89
90 my $future = DateTime::Infinite::Future->new;
91 my $past = DateTime::Infinite::Past->new;
92
93=head1 DESCRIPTION
94
95This module provides two L<DateTime.pm|DateTime> subclasses,
96C<DateTime::Infinite::Future> and C<DateTime::Infinite::Past>.
97
98The objects are in the "floating" timezone, and this cannot be
99changed.
100
101=head1 BUGS
102
103There seem to be lots of problems when dealing with infinite numbers
104on Win32. This may be a problem with this code, Perl, or Win32's IEEE
105math implementation. Either way, the module may not be well-behaved
106on Win32 operating systems.
107
108=head1 METHODS
109
110The only constructor for these two classes is the C<new()> method, as
111shown in the L<SYNOPSIS|/SYNOPSIS>. This method takes no parameters.
112
113All "get" methods in this module simply return infinity, positive or
114negative. If the method is expected to return a string, it return the
115string representation of positive or negative infinity used by your
116system. For example, on my system calling C<year()> returns a number
117which when printed appears either "inf" or "-inf".
118
119The object is not mutable, so the C<set()>, C<set_time_zone()>, and
120C<truncate()> methods are all do-nothing methods that simply return
121the object they are called with.
122
123Obviously, the C<is_finite()> method returns false and the
124C<is_infinite()> method returns true.
125
126=head1 AUTHOR
127
128Dave Rolsky <autarch@urth.org>
129
130=head1 COPYRIGHT
131
132Copyright (c) 2003-2009 David Rolsky. All rights reserved. This
133program is free software; you can redistribute it and/or modify it
134under the same terms as Perl itself.
135
136The full text of the license can be found in the LICENSE file included
137with this module.
138
139=head1 SEE ALSO
140
141datetime@perl.org mailing list
142
143http://datetime.perl.org/
144
145=cut
146