Time::y2038(3pm)
π Time::y2038 β NAME β¨
okay so bestie, this page is for Time::y2038, which is literally just versions of Perl's time functions that still work past the year 2038 π no cap.
π¦ SYNOPSIS
use Time::y2038;
print scalar gmtime 2**52; # Sat Dec 6 03:48:16 142715360
π DESCRIPTION
So here's the tea π: on many computers, Perl's time functions justβ¦ stop working past the year 2038. Not a Perl problem exactly β it's a design fault in the underlying C libraries Perl leans on. Kinda iconic of them, lowkey tragic though. π
Time::y2038 hands you replacements for those functions that are accurate to +/1 142 million years β¨. That's the whole point. That's the moment.
heads up, bestie: this module only imports the functions into your namespace. If you want them swapped out everywhere, go look at Time::y2038::Everywhere π
It replaces the following functions:
π
gmtime()
See "gmtime" in perlfunc for the deets.
π
localtime()
See "localtime" in perlfunc for the deets.
π«Ά timegm()
my $time = timegm($sec, $min, $hour, $month_day, $month, $year);
The inverse of gmtime() β you feed it a date and it gives you back the coorsponding $time (number of seconds since Midnight, January 1st, 1970 GMT) β°. All the values work the same as gmtime(), so $month is 0..11 (January is 0) and the $year is years since 1900 (so 2008 is 108). mmkay?
# June 4, 1906 03:02:01 GMT
my $time = timegm(1, 2, 3, 4, 5, 6);
timegm() can also take two additional arguments which are always ignored π. Why? So you can yeet the results from gmtime() straight back into timegm() without having to strip the extra args off first. Convenient, right?
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(), except it interprets the date in the current time zone π.
timelocal() will normally figure out on its own whether daylight savings time is in effect β but if you hand it $isdst, that overrides the check π. This is mostly useful for resolving those ambiguous times around "fall back", when the hour between 1am and 2am literally happens twice. Time is a scam fr fr.
# 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're only there so it stays compatible with what localtime() gives you back.
β οΈ LIMITATIONS β οΈ
The safe range of times is +/ 2**52 β that's about 142 million years π.
Even though the underlying time library can handle times from -263 to 263-1 (roughly +/- 292 billion years π), Perl uses floating point numbers internally, so accuracy degrates after 2**52. Yeah. That's the tradeoff, bestie. π
π BUGS & FEEDBACK π
Wanna report a bug or lurk on the existing ones? Go here:
http://rt.cpan.org/Dist/Display.html?Queue=Time-y2038
If you like the module, pleeeease drop the author an email π«Ά he will be so happy.
The latest version of this module lives at http://y2038.googlecode.com/, and the repository is at http://y2038.googlecode.com/svn/trunk/ in perl/Time-y2038. Heads up: you have to check out the whole repository, because there are symlinks in there π β you can't just grab the one directory, it's giving "trust the process".
π AUTHOR π
Michael G Schwern <schwern@pobox.com> π
π LICENSE & COPYRIGHT π
Copyright 2008-2010 Michael G Schwern
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself β¨.
See http://www.perl.com/perl/misc/Artistic.html
π SEE ALSO π
Time::y2038::Everywhereβ overrideslocaltime()andgmtime()across the whole program. Main character energy fr.- The y2038 project at
http://y2038.googlecode.com/ <http://xkcd.com/376/>πΈ (iykyk)
and that's the whole page bestie π this was perl v5.42.3, dated 2026-08-19, serving Time::y2038(3pm) realness. go forth and be y2038-proof π¦β¨ periodt π
π¦ where this page comes from
- ubuntu stonking: libtime-y2038-perl 20100403-7build5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms