summaryrefslogtreecommitdiff
path: root/lib/Time
diff options
context:
space:
mode:
authorH.Merijn Brand <h.m.brand@xs4all.nl>2004-04-07 17:54:10 +0000
committerH.Merijn Brand <h.m.brand@xs4all.nl>2004-04-07 17:54:10 +0000
commit4ab0373fd39c5730a2e94dc529349ae645b4daca (patch)
tree7b133c4be24d8ddbb02cbd0507428113dfb3bdbf /lib/Time
parentee80afe69a0e0464a9d27967d995a4791cf8367b (diff)
downloadperl-4ab0373fd39c5730a2e94dc529349ae645b4daca.tar.gz
Integrated Time-Local-1.09 from Dave Rolsky
Corrected a wrap error from the CPAN version to match #22670 Tested on AIX to make sure the skip is still needed p4raw-id: //depot/perl@22671
Diffstat (limited to 'lib/Time')
-rw-r--r--lib/Time/Local.pm30
-rwxr-xr-xlib/Time/Local.t30
2 files changed, 40 insertions, 20 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm
index 6b38c303ae..a0506d250d 100644
--- a/lib/Time/Local.pm
+++ b/lib/Time/Local.pm
@@ -7,7 +7,7 @@ use strict;
use integer;
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
-$VERSION = '1.07_94';
+$VERSION = '1.09';
$VERSION = eval $VERSION;
@ISA = qw( Exporter );
@EXPORT = qw( timegm timelocal );
@@ -210,7 +210,7 @@ Time::Local - efficiently compute time from local and GMT time
These routines are the inverse of built-in perl functions localtime()
and gmtime(). They accept a date as a six-element array, and return
the corresponding time(2) value in seconds since the system epoch
-(Midnight, January 1, 1970 UTC on Unix, for example). This value can
+(Midnight, January 1, 1970 GMT on Unix, for example). This value can
be positive or negative, though POSIX only requires support for
positive values, so dates before the system's epoch may not work on
all operating systems.
@@ -253,7 +253,7 @@ values, the following conventions are followed:
Years greater than 999 are interpreted as being the actual year,
rather than the offset from 1900. Thus, 1963 would indicate the year
-Martin Luther King won the Nobel prize, not the year 2863.
+Martin Luther King won the Nobel prize, not the year 3863.
=item *
@@ -286,15 +286,25 @@ range.
=head2 Ambiguous Local Times (DST)
Because of DST changes, there are many time zones where the same local
-time occurs for two different UTC times on the same day. For example,
+time occurs for two different GMT times on the same day. For example,
in the "Europe/Paris" time zone, the local time of 2001-10-28 02:30:00
-can represent either 2001-10-28 00:30:00 UTC, B<or> 2001-10-28
-01:30:00 UTC.
+can represent either 2001-10-28 00:30:00 GMT, B<or> 2001-10-28
+01:30:00 GMT.
When given an ambiguous local time, the timelocal() function should
-always return the epoch for the I<earlier> of the two possible UTC
+always return the epoch for the I<earlier> of the two possible GMT
times.
+=head2 Non-Existent Local Times (DST)
+
+When a DST change causes a locale clock to skip one hour forward,
+there will be an hour's worth of local times that don't exist. Again,
+for the "Europe/Paris" time zone, the local clock jumped from
+2001-03-25 01:59:59 to 2001-03-25 03:00:00.
+
+If the 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
Negative epoch (time_t) values are not officially supported by the
@@ -328,11 +338,11 @@ The whole scheme for interpreting two-digit years can be considered a bug.
=head1 SUPPORT
-Support for this module is provided via the perl5-porters@perl.org
+Support for this module is provided via the datetime@perl.org
email list. See http://lists.perl.org/ for more details.
-Please submit bugs using the RT system at bugs.perl.org, the perlbug
-script, or as a last resort, to the perl5-porters@perl.org list.
+Please submit bugs using the RT system at rt.cpan.org, or as a last
+resort, to the datetime@perl.org list.
=head1 AUTHOR
diff --git a/lib/Time/Local.t b/lib/Time/Local.t
index 8f35f7aa60..06db37e659 100755
--- a/lib/Time/Local.t
+++ b/lib/Time/Local.t
@@ -36,7 +36,7 @@ if ($^O eq 'VMS') { $time[0][2]++ }
my $tests = (@time * 12) + 6;
$tests += 2 if $ENV{PERL_CORE};
-$tests += 3 if $ENV{MAINTAINER};
+$tests += 5 if $ENV{MAINTAINER};
plan tests => $tests;
@@ -63,9 +63,9 @@ for (@time) {
if ($^O eq 'vos' && $year == 70) {
skip(1, "skipping 1970 test on VOS.\n") for 1..6;
} else {
- my $time = timelocal($sec,$min,$hour,$mday,$mon,$year);
+ my $time = timegm($sec,$min,$hour,$mday,$mon,$year);
- my($s,$m,$h,$D,$M,$Y) = localtime($time);
+ my($s,$m,$h,$D,$M,$Y) = gmtime($time);
ok($s, $sec, 'second');
ok($m, $min, 'minute');
@@ -100,13 +100,13 @@ ok(timegm(0,0,0, 1, 2, 80) - timegm(0,0,0, 1, 0, 80), 60 * 24 * 3600,
# round trip was broken for edge cases
if ($^O eq "aix" && $Config{osvers} =~ m/^4\.3\./) {
-skip ("No fix expected for edge case test for $_ on AIX 4.3") for qw( timegm timelocal );
+ skip ("No fix expected for edge case test for $_ on AIX 4.3") for qw( timegm timelocal );
} else {
-ok(sprintf('%x', timegm(gmtime(0x7fffffff))), sprintf('%x', 0x7fffffff),
- '0x7fffffff round trip through gmtime then timegm');
+ ok(sprintf('%x', timegm(gmtime(0x7fffffff))), sprintf('%x', 0x7fffffff),
+ '0x7fffffff round trip through gmtime then timegm');
-ok(sprintf('%x', timelocal(localtime(0x7fffffff))), sprintf('%x', 0x7fffffff),
- '0x7fffffff round trip through localtime then timelocal');
+ ok(sprintf('%x', timelocal(localtime(0x7fffffff))), sprintf('%x', 0x7fffffff),
+ '0x7fffffff round trip through localtime then timelocal');
}
if ($ENV{MAINTAINER}) {
@@ -127,12 +127,16 @@ if ($ENV{MAINTAINER}) {
local $ENV{TZ} = 'America/Chicago';
POSIX::tzset();
- # Same local time in America/Chicago. There is transition here as
- # well.
+ # Same local time in America/Chicago. There is a transition
+ # here as well.
$time = timelocal(0, 30, 1, 28, 9, 101);
ok($time, 1004250600,
'timelocal prefers earlier epoch in the presence of a DST change');
+ $time = timelocal(0, 30, 2, 1, 3, 101);
+ ok($time, 986113800,
+ 'timelocal for non-existent time gives you the time one hour later');
+
local $ENV{TZ} = 'Australia/Sydney';
POSIX::tzset();
@@ -142,12 +146,18 @@ if ($ENV{MAINTAINER}) {
$time = timelocal(0, 30, 2, 25, 2, 101);
ok($time, 985447800,
'timelocal prefers earlier epoch in the presence of a DST change');
+
+ $time = timelocal(0, 30, 2, 28, 9, 101);
+ ok($time, 1004200200,
+ 'timelocal for non-existent time gives you the time one hour later');
}
}
if ($ENV{PERL_CORE}) {
package test;
require 'timelocal.pl';
+
+ # need to get ok() from main package
::ok(timegm(0,0,0,1,0,80), main::timegm(0,0,0,1,0,80),
'timegm in timelocal.pl');