From 11c6e5fc65f26ba5219997d19707b998a9abf26d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 7 Mar 2020 22:52:33 +0000 Subject: tl20 perl 5.30.1 for Windows, from Siep git-svn-id: svn://tug.org/texlive/trunk@54166 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tlperl/lib/Time/Local.pm | 83 ++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 17 deletions(-) (limited to 'Master/tlpkg/tlperl/lib/Time/Local.pm') diff --git a/Master/tlpkg/tlperl/lib/Time/Local.pm b/Master/tlpkg/tlperl/lib/Time/Local.pm index 65d7d588458..b5a62bb52dd 100644 --- a/Master/tlpkg/tlperl/lib/Time/Local.pm +++ b/Master/tlpkg/tlperl/lib/Time/Local.pm @@ -5,12 +5,13 @@ use strict; use Carp (); use Exporter; -our $VERSION = '1.25'; +our $VERSION = '1.28'; use parent 'Exporter'; -our @EXPORT = qw( timegm timelocal ); -our @EXPORT_OK = qw( timegm_nocheck timelocal_nocheck ); +our @EXPORT = qw( timegm timelocal ); +our @EXPORT_OK + = qw( timegm_modern timelocal_modern timegm_nocheck timelocal_nocheck ); my @MonthDays = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); @@ -62,9 +63,9 @@ if ( $^O eq 'vos' ) { $Epoc = _daygm( 0, 0, 0, 1, 0, 70, 4, 0 ); } elsif ( $^O eq 'MacOS' ) { - $MaxDay *= 2 if $^O eq 'MacOS'; # time_t unsigned ... quick hack? - # MacOS time() is seconds since 1 Jan 1904, localtime - # so we need to calculate an offset to apply later + $MaxDay *= 2; # time_t unsigned ... quick hack? + # MacOS time() is seconds since 1 Jan 1904, localtime + # so we need to calculate an offset to apply later $Epoc = 693901; $SecOff = timelocal( localtime(0) ) - timelocal( gmtime(0) ); $Epoc += _daygm( gmtime(0) ); @@ -73,7 +74,7 @@ else { $Epoc = _daygm( gmtime(0) ); } -%Cheat = (); # clear the cache as epoc has changed +%Cheat = (); # clear the cache as epoc has changed sub _daygm { @@ -105,11 +106,16 @@ sub _timegm { sub timegm { my ( $sec, $min, $hour, $mday, $month, $year ) = @_; - if ( $year >= 1000 ) { + if ( $Options{no_year_munging} ) { $year -= 1900; } - elsif ( $year < 100 and $year >= 0 ) { - $year += ( $year > $Breakpoint ) ? $Century : $NextCentury; + else { + if ( $year >= 1000 ) { + $year -= 1900; + } + elsif ( $year < 100 and $year >= 0 ) { + $year += ( $year > $Breakpoint ) ? $Century : $NextCentury; + } } unless ( $Options{no_range_check} ) { @@ -164,6 +170,11 @@ sub timegm_nocheck { return &timegm; } +sub timegm_modern { + local $Options{no_year_munging} = 1; + return &timegm; +} + sub timelocal { my $ref_t = &timegm; my $loc_for_ref_t = _timegm( localtime($ref_t) ); @@ -184,7 +195,7 @@ sub timelocal { !$dst_off && ( ( $ref_t - SECS_PER_HOUR ) - _timegm( localtime( $loc_t - SECS_PER_HOUR ) ) < 0 ) - ) { + ) { return $loc_t - SECS_PER_HOUR; } @@ -206,6 +217,11 @@ sub timelocal_nocheck { return &timelocal; } +sub timelocal_modern { + local $Options{no_year_munging} = 1; + return &timelocal; +} + 1; # ABSTRACT: Efficiently compute time from local and GMT time @@ -222,7 +238,7 @@ Time::Local - Efficiently compute time from local and GMT time =head1 VERSION -version 1.25 +version 1.28 =head1 SYNOPSIS @@ -247,6 +263,28 @@ consistent with the values returned from C and C. =head1 FUNCTIONS +=head2 C and C + +When C was first written, it was a common practice to represent +years as a two-digit value like C<99> for C<1999> or C<1> for C<2001>. This +caused all sorts of problems (google "Y2K problem" if you're very young) and +developers eventually realized that this was a terrible idea. + +The default exports of C and C do a complicated +calculation when given a year value less than 1000. This leads to surprising +results in many cases. See L for details. + +The C subs do not do this year munging and simply take the +year value as provided. + +While it would be nice to make this the default behavior, that would almost +certainly break a lot of code, so you must explicitly import these subs and +use them instead of the default C and C. + +You are B encouraged to use these subs in any new code which uses +this module. It will almost certainly make your code's behavior less +surprising. + =head2 C and C This module exports two functions by default, C and C. @@ -270,6 +308,9 @@ will be unpredictable (so don't do that). =head2 Year Value Interpretation +B or C. Use those +exports if you want to ensure consistent behavior as your code ages.> + Strictly speaking, the year should be specified in a form consistent with C, i.e. the offset from 1900. In order to make the interpretation of the year easier for humans, however, who are more accustomed to seeing @@ -314,9 +355,10 @@ approximate range from Dec 1901 to Jan 2038. Both C and C 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). +As of version 5.12.0, perl has stopped using the time implementation of the +operating system it's running on. Instead, it 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) @@ -378,13 +420,17 @@ The current version was written by Graham Barr. The whole scheme for interpreting two-digit years can be considered a bug. -Bugs may be submitted through L. +Bugs may be submitted at L. There is a mailing list available for users of this distribution, L. I am also usually active on IRC as 'autarch' on C. +=head1 SOURCE + +The source code repository for Time-Local can be found at L. + =head1 AUTHOR Dave Rolsky @@ -411,9 +457,12 @@ Unknown =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 1997 - 2016 by Graham Barr & Dave Rolsky. +This software is copyright (c) 1997 - 2018 by Graham Barr & Dave Rolsky. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. +The full text of the license can be found in the +F file included with this distribution. + =cut -- cgit v1.2.3