On many computers, Perl's time functions will not work past the year 2038. This is a design fault in the
underlying C libraries Perl uses. Time::y2038 provides replacements for those functions which will work
accurately +/1 142 million years.
This only imports the functions into your namespace. To replace it everywhere, see
Time::y2038::Everywhere.
Replaces the following functions:
gmtime()
See "gmtime" in perlfunc for details.
localtime()
See "localtime" in perlfunc for details.
timegm()
my $time = timegm($sec, $min, $hour, $month_day, $month, $year);
The inverse of gmtime(), takes a date and returns the coorsponding $time (number of seconds since
Midnight, January 1st, 1970 GMT). All values are the same as gmtime() so $month is 0..11 (January is 0)
and the $year is years since 1900 (2008 is 108).
# June 4, 1906 03:02:01 GMT
my $time = timegm(1, 2, 3, 4, 5, 6);
timegm() can take two additional arguments which are always ignored. This lets you feed the results from
gmtime() back into timegm() without having to strip the arguments off.
The following is always true:
timegm(gmtime($time)) == $time;
timelocal()
my $time = timelocal($sec, $min, $hour, $mday, $month, $year);
my $time = timelocal($sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst);
Like timegm(), but interprets the date in the current time zone.
timelocal() will normally figure out if daylight savings time is in effect, but if $isdst is given this
will override that check. This is mostly useful to resolve ambiguous times around "fall back" when the
hour between 1am and 2am occurs twice.
# Sun Nov 4 00:59:59 2007
print timelocal(59, 59, 0, 4, 10, 107); # 1194163199
# Sun Nov 4 01:00:00 2007 DST, one second later
print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 1); # 1194163200
# Sun Nov 4 01:00:00 2007 no DST, one hour later
print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 0); # 1194166800
$wday and $yday are ignored. They are only there for compatibility with the return value of localtime().