1Time::y2038(3) User Contributed Perl Documentation Time::y2038(3)
2
3
4
6 Time::y2038 - Versions of Perl's time functions which work beyond 2038
7
9 use Time::y2038;
10
11 print scalar gmtime 2**52; # Sat Dec 6 03:48:16 142715360
12
14 On many computers, Perl's time functions will not work past the year
15 2038. This is a design fault in the underlying C libraries Perl uses.
16 Time::y2038 provides replacements for those functions which will work
17 accurately +/1 142 million years.
18
19 This only imports the functions into your namespace. To replace it
20 everywhere, see Time::y2038::Everywhere.
21
22 Replaces the following functions:
23
24 gmtime()
25
26 See "gmtime" in perlfunc for details.
27
28 localtime()
29
30 See "localtime" in perlfunc for details.
31
32 timegm()
33
34 my $time = timegm($sec, $min, $hour, $month_day, $month, $year);
35
36 The inverse of "gmtime()", takes a date and returns the coorsponding
37 $time (number of seconds since Midnight, January 1st, 1970 GMT). All
38 values are the same as "gmtime()" so $month is 0..11 (January is 0) and
39 the $year is years since 1900 (2008 is 108).
40
41 # June 4, 1906 03:02:01 GMT
42 my $time = timegm(1, 2, 3, 4, 5, 6);
43
44 timegm() can take two additional arguments which are always ignored.
45 This lets you feed the results from gmtime() back into timegm() without
46 having to strip the arguments off.
47
48 The following is always true:
49
50 timegm(gmtime($time)) == $time;
51
52 timelocal()
53
54 my $time = timelocal($sec, $min, $hour, $mday, $month, $year);
55 my $time = timelocal($sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst);
56
57 Like "timegm()", but interprets the date in the current time zone.
58
59 "timelocal()" will normally figure out if daylight savings time is in
60 effect, but if $isdst is given this will override that check. This is
61 mostly useful to resolve ambiguous times around "fall back" when the
62 hour between 1am and 2am occurs twice.
63
64 # Sun Nov 4 00:59:59 2007
65 print timelocal(59, 59, 0, 4, 10, 107); # 1194163199
66
67 # Sun Nov 4 01:00:00 2007 DST, one second later
68 print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 1); # 1194163200
69
70 # Sun Nov 4 01:00:00 2007 no DST, one hour later
71 print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 0); # 1194166800
72
73 $wday and $yday are ignored. They are only there for compatibility
74 with the return value of "localtime()".
75
77 The safe range of times is +/ 2**52 (about 142 million years).
78
79 Although the underlying time library can handle times from -2**63 to
80 2**63-1 (about +/- 292 billion years) Perl uses floating point numbers
81 internally and so accuracy degrates after 2**52.
82
84 See http://rt.cpan.org/Dist/Display.html?Queue=Time-y2038 to report and
85 view bugs.
86
87 If you like the module, please drop the author an email.
88
89 The latest version of this module can be found at
90 http://y2038.googlecode.com/ and the repository is at
91 http://y2038.googlecode.com/svn/trunk/ in perl/Time-y2038. You have to
92 check out the whole repository because there are symlinks.
93
95 Michael G Schwern <schwern@pobox.com>
96
98 Copyright 2008-2010 Michael G Schwern
99
100 This program is free software; you can redistribute it and/or modify it
101 under the same terms as Perl itself.
102
103 See http://www.perl.com/perl/misc/Artistic.html
104
106 Time::y2038::Everywhere overrides localtime() and gmtime() across the
107 whole program.
108
109 The y2038 project at http://y2038.googlecode.com/
110
111 <http://xkcd.com/376/>
112
113
114
115perl v5.34.0 2021-07-27 Time::y2038(3)