summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Time/Local.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Time/Local.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Time/Local.pm49
1 files changed, 46 insertions, 3 deletions
diff --git a/Master/tlpkg/tlperl/lib/Time/Local.pm b/Master/tlpkg/tlperl/lib/Time/Local.pm
index 96a688d92c4..0e9c4ac467c 100644
--- a/Master/tlpkg/tlperl/lib/Time/Local.pm
+++ b/Master/tlpkg/tlperl/lib/Time/Local.pm
@@ -6,7 +6,7 @@ use Config;
use strict;
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
-$VERSION = '1.1901_01';
+$VERSION = '1.2000';
@ISA = qw( Exporter );
@EXPORT = qw( timegm timelocal );
@@ -28,8 +28,23 @@ use constant SECS_PER_MINUTE => 60;
use constant SECS_PER_HOUR => 3600;
use constant SECS_PER_DAY => 86400;
-# localtime()'s limit is the year 2**31
-my $MaxDay = 365 * (2**31);
+my $MaxDay;
+if ($] < 5.012000) {
+ my $MaxInt;
+ if ( $^O eq 'MacOS' ) {
+ # time_t is unsigned...
+ $MaxInt = ( 1 << ( 8 * $Config{ivsize} ) ) - 1;
+ }
+ else {
+ $MaxInt = ( ( 1 << ( 8 * $Config{ivsize} - 2 ) ) - 1 ) * 2 + 1;
+ }
+
+ $MaxDay = int( ( $MaxInt - ( SECS_PER_DAY / 2 ) ) / SECS_PER_DAY ) - 1;
+}
+else {
+ # recent localtime()'s limit is the year 2**31
+ $MaxDay = 365 * (2**31);
+}
# Determine the EPOC day for this machine
my $Epoc = 0;
@@ -266,6 +281,21 @@ absolute four digit year instead.
The scheme above allows interpretation of a wide range of dates,
particularly if 4-digit years are used.
+=head2 Limits of time_t
+
+On perl versions older than 5.12.0, the range of dates that can be
+actually be handled depends on the size of C<time_t> (usually a signed
+integer) on the given platform. Currently, this is 32 bits for most
+systems, yielding an approximate range from Dec 1901 to Jan 2038.
+
+Both C<timelocal()> and C<timegm()> croak if given dates outside the
+supported range.
+
+As of version 5.12.0, perl has stopped using the underlying time
+library of the operating system it's running on and has its own
+implementation of those routines with a safe range of at least
++/ 2**52 (about 142 million years).
+
=head2 Ambiguous Local Times (DST)
Because of DST changes, there are many time zones where the same local
@@ -288,6 +318,19 @@ for the "Europe/Paris" time zone, the local clock jumped from
If the C<timelocal()> function is given a non-existent local time, it
will simply return an epoch value for the time one hour later.
+=head2 Negative Epoch Values
+
+On perl version 5.12.0 and newer, negative epoch values are fully
+supported.
+
+On older versions of perl, negative epoch (C<time_t>) values, which
+are not officially supported by the POSIX standards, are known not to
+work on some systems. These include MacOS (pre-OSX) and Win32.
+
+On systems which do support negative epoch values, this module should
+be able to cope with dates before the start of the epoch, down the
+minimum value of time_t for the system.
+
=head1 IMPLEMENTATION
These routines are quite efficient and yet are always guaranteed to