summaryrefslogtreecommitdiff
path: root/lib/Time
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2008-09-29 12:07:29 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-01-03 18:38:49 +0100
commit4c91ace1ab7f54d4e52467ee37e480e29b555047 (patch)
treedc36757714ec56e3a192ca05a09ec377c669e03d /lib/Time
parentdc164757d6434bcc04e6bf2256aab2dea31afaa0 (diff)
downloadperl-4c91ace1ab7f54d4e52467ee37e480e29b555047.tar.gz
Everything should now work with negative times, so let's pull out all the skips from the tests.
Diffstat (limited to 'lib/Time')
-rwxr-xr-xlib/Time/Local.t47
-rw-r--r--lib/Time/localtime.t21
2 files changed, 22 insertions, 46 deletions
diff --git a/lib/Time/Local.t b/lib/Time/Local.t
index ef32b40405..17e811583f 100755
--- a/lib/Time/Local.t
+++ b/lib/Time/Local.t
@@ -62,17 +62,6 @@ my @years =
[ 2100 => 0 ],
);
-# Use 3 days before the start of the epoch because with Borland on
-# Win32 it will work for -3600 _if_ your time zone is +01:00 (or
-# greater).
-my $neg_epoch_ok = defined ((localtime(-259200))[0]) ? 1 : 0;
-
-# use vmsish 'time' makes for oddness around the Unix epoch
-if ($^O eq 'VMS') {
- $time[0][2]++;
- $neg_epoch_ok = 0; # time_t is unsigned
-}
-
my $tests = (@time * 12);
$tests += @neg_time * 12;
$tests += @bad_time;
@@ -88,28 +77,23 @@ for (@time, @neg_time) {
$year -= 1900;
$mon--;
- SKIP: {
- skip '1970 test on VOS fails.', 12
- if $^O eq 'vos' && $year == 70;
- skip 'this platform does not support negative epochs.', 12
- if $year < 70 && ! $neg_epoch_ok;
-
- {
- my $year_in = $year < 70 ? $year + 1900 : $year;
- my $time = timelocal($sec,$min,$hour,$mday,$mon,$year_in);
-
- my($s,$m,$h,$D,$M,$Y) = localtime($time);
-
- is($s, $sec, "timelocal second for @$_");
- is($m, $min, "timelocal minute for @$_");
- is($h, $hour, "timelocal hour for @$_");
- is($D, $mday, "timelocal day for @$_");
- is($M, $mon, "timelocal month for @$_");
- is($Y, $year, "timelocal year for @$_");
- }
+ # Test timelocal()
+ {
+ my $year_in = $year < 70 ? $year + 1900 : $year;
+ my $time = timelocal($sec,$min,$hour,$mday,$mon,$year_in);
+
+ my($s,$m,$h,$D,$M,$Y) = localtime($time);
+
+ is($s, $sec, "timelocal second for @$_");
+ is($m, $min, "timelocal minute for @$_");
+ is($h, $hour, "timelocal hour for @$_");
+ is($D, $mday, "timelocal day for @$_");
+ is($M, $mon, "timelocal month for @$_");
+ is($Y, $year, "timelocal year for @$_");
}
- # Perl has its own gmtime()
+
+ # Test timegm()
{
my $year_in = $year < 70 ? $year + 1900 : $year;
my $time = timegm($sec,$min,$hour,$mday,$mon,$year_in);
@@ -125,6 +109,7 @@ for (@time, @neg_time) {
}
}
+
for (@bad_time) {
my($year, $mon, $mday, $hour, $min, $sec) = @$_;
$year -= 1900;
diff --git a/lib/Time/localtime.t b/lib/Time/localtime.t
index 10df765fc3..8600eff3e7 100644
--- a/lib/Time/localtime.t
+++ b/lib/Time/localtime.t
@@ -8,30 +8,21 @@ BEGIN {
}
BEGIN {
- my $haslocal;
- eval { my $n = localtime 0 };
- $haslocal = 1 unless $@ && $@ =~ /unimplemented/;
+ @times = (-2**33, -2**31-1, 0, 2**31-1, 2**33, time);
+ @methods = qw(sec min hour mday mon year wday yday isdst);
- skip_all("no localtime") unless $haslocal;
-}
-
-BEGIN {
- my @localtime = CORE::localtime 0; # This is the function localtime.
+ plan tests => (@times * @methods) + 1;
- skip_all("localtime failed") unless @localtime;
+ use_ok Time::localtime;
}
-BEGIN { plan tests => 37; }
-
-BEGIN { use_ok Time::localtime; }
-
# Since Perl's localtime() still uses the system localtime, don't try
# to do negative times. The system might not support it.
-for my $time (0, 2**31-1, 2**33, time) {
+for my $time (@times) {
my $localtime = localtime $time; # This is the OO localtime.
my @localtime = CORE::localtime $time; # This is the localtime function
- for my $method (qw(sec min hour mday mon year wday yday isdst)) {
+ for my $method (@methods) {
is $localtime->$method, shift @localtime, "localtime($time)->$method";
}
}