NAME
DateTime::Lite::Infinite - Infinite past and future DateTime::Lite objects
SYNOPSIS
use DateTime::Lite::Infinite;
my $future = DateTime::Lite::Infinite::Future->new;
my $past = DateTime::Lite::Infinite::Past->new;
# Predicates
$future->is_infinite; # 1
$future->is_finite; # 0
$past->is_infinite; # 1
$past->is_finite; # 0
# String representation
# All accessor methods return the platform's infinity string, such as "Inf" /
# "-Inf". Stringification is also available directly:
print $future->stringify; # "Inf"
print "$past"; # "-Inf"
# hour_12 and hour_12_0 also return the infinity string:
$future->hour_12; # "Inf"
$future->hour_12_0; # "Inf"
# Comparison
use DateTime::Lite;
my $dt = DateTime::Lite->now( time_zone => 'UTC' );
DateTime::Lite->compare( $dt, $future ); # -1 ($dt is earlier)
DateTime::Lite->compare( $dt, $past ); # 1 ($dt is later)
DateTime::Lite->compare( $future, $past ); # 1
# Overloaded operators work too:
print "before end of time" if( $dt < $future );
print "after beginning" if( $dt > $past );
# Arithmetic that yields infinite datetimes
use DateTime::Lite;
my $dt2 = DateTime::Lite->now( time_zone => 'UTC' );
my $inf_dur = DateTime::Lite::Duration->new(
seconds => DateTime::Lite::INFINITY(),
);
$dt2->add_duration( $inf_dur );
# $dt2 is now a DateTime::Lite::Infinite::Future object
# Mutators are no-ops
# set(), set_time_zone(), and truncate() return the object unchanged.
$future->set_time_zone('America/New_York'); # no-op
$future->truncate( to => 'day' ); # no-op
VERSION
v0.1.0
DESCRIPTION
DateTime::Lite::Infinite provides two singleton subclasses of DateTime::Lite:
DateTime::Lite::Infinite::Future-
Represents a point infinitely far in the future.
DateTime::Lite::Infinite::Past-
Represents a point infinitely far in the past.
Both objects are always in the floating timezone, which cannot be changed.
All accessor methods return the system's string representation of positive or negative infinity (such as Inf / -Inf). The mutating methods set(), set_time_zone(), and truncate() are no-ops that simply return the object.
These objects are not serialisable via Storable.
METHODS
hour_12
my $h = $dt_inf->hour_12; # 'Inf' or '-Inf'
Returns the infinity string (Inf or -Inf depending on the system) as the 12-hour clock representation. Infinite datetimes have no meaningful clock value.
hour_12_0
my $h = $dt_inf->hour_12_0;
Identical to "hour_12". Returns the infinity string for the 0-based 12-hour clock slot.
stringify
my $str = "$dt_inf"; # 'DateTime::Lite::Infinite::Future' prints 'Inf'
Returns the infinity string representation of the object. This is also called by the "" overloading operator.
SEE ALSO
DateTime::Lite, DateTime::Lite::Duration
AUTHOR
Jacques Deguest <jack@deguest.jp>
COPYRIGHT & LICENSE
Copyright(c) 2026 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.