NAME
Time::Local::Extended - Increase the range of localtime and timelocal
SYNOPSIS
use Time::Local::Extended qw(:ALL);
my @localtime = localtime(2**31);
my $seconds = timelocal(0,0,0,1,10,170);
my $gmt_seconds = timegm(0,0,0,1,10,170);
my $gmt_time = gmtime(2**31);
my $ux_time = UNIX_TIMESTAMP('2097-07-04 12:34:56');
my $date = FROM_UNIXTIME(2**31);
my $sql = qq(
SELECT start_time
FROM project
WHERE id = 1
);
my $date_time = $dbh->selectrow_array($sql); # '2097-07-04 12:34:56'
my $ux_time = UNIX_TIMESTAMP($date_time); # 4023794096
my $date_time = FROM_UNIXTIME(2**31);
my $sql = qq(
UPDATE project
SET start_time = ?
WHERE id = 1
);
$dbh->do($sql, undef, $date_time);
DESCRIPTION
This module extends the date range of localtime(), gmtime(), timegm() and timelocal() to go safely beyond 2038 and before 1970 on any operating system.
It also provides a handful of useful time conversion functions.
PUBLIC FUNCTIONS
timelocal
Invoked in the same way as Time::Local::timelocal().
localtime
Invoked in the same way as CORE::localtime().
timegm
Invoked in the same way as Time::Local::timegm().
gmtime
Invoked in the same way as CORE::gmtime().
UNIX_TIMESTAMP
Invoked similarly to the MySQL UNIX_TIMESTAMP() function()
FROM_UNIXTIME
Invoked similarly to the MySQL FROM_UNIXTIME() function()
LIMITATIONS
Because of the way timegm() and timelocal() try to Do What You Mean with the year, it is impossible to feed it the years 0 through 99 (it thinks you mean 2000 - 2099).
While the code can in theory go out to 2**63, the practical portable limit of this code is from 2**52 to -2**52 (the limit of double floating point precision) after which precision starts to drop off. This gives you a range of about +/- 142 million years.
BUGS
Please e-mail bug reports or suggestions to bobo@cpan.org. Thanks!
CREDITS
Thanks to Michael Schwern for extending this module's capabilities beyond 2098.
Thanks to Peter Kioko for helping to refine the idea, and Adam Foxson, the Human CPAN Reference Manual, for quality assurance.
AUTHOR
Bob O'Neill, <bobo@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2003-2008 Bob O'Neill and Michael Schwern. All rights reserved.
See COPYING for license