Subject: | Recent and Vague tests fail |
In the 02recent.t and 09vague.t test files, the date to be tested
against is a hard-coded epoch-seconds value. However, the tests depend
upon the local time interpretation of this value and therefore fail in
most timezones other than the one for which the epoch-seconds value was
calculated.
I have attached a patch that corrects this by creating the epoch-seconds
test value via timelocal() to ensure the proper timezone-specific
adjustments are made.
Cheers,
Doug
Subject: | Date-PeriodParser-0.06.patch |
diff -PurN Date-PeriodParser-0.06.orig/t/02recent.t Date-PeriodParser-0.06/t/02recent.t
--- Date-PeriodParser-0.06.orig/t/02recent.t 2005-02-07 20:26:11.000000000 -0500
+++ Date-PeriodParser-0.06/t/02recent.t 2007-10-17 14:58:31.000000000 -0400
@@ -8,8 +8,9 @@
# /^(last |to)night/ ||
# /^(yesterday|tomorrow) (morning|afternoon|evening)$/ ||
BEGIN {
-# Set the base time we use for tests (22:01:36 12/4/2002)
-$Date::PeriodParser::TestTime = $base = 1018674096;
+# Set the base time we use for tests (Fri Apr 12 22:01:36 2002)
+$Date::PeriodParser::TestTime = $base =
+ timelocal( '36', '1', '22', '12', '3', '102' );
my ($s, $mn, $h, $d, $m, $y, $wd, $yd, $dst) = localtime($base);
sub slt { scalar localtime timelocal @_ }
diff -PurN Date-PeriodParser-0.06.orig/t/09vague.t Date-PeriodParser-0.06/t/09vague.t
--- Date-PeriodParser-0.06.orig/t/09vague.t 2005-02-07 20:26:11.000000000 -0500
+++ Date-PeriodParser-0.06/t/09vague.t 2007-10-17 14:57:22.000000000 -0400
@@ -1,28 +1,39 @@
use Test::More tests=>8;
use Time::Local;
use Date::PeriodParser;
+use vars qw( $Date::PeriodParser::TestTime );
{
- $Date::PeriodParser::TestTime = $base = 1018674096;
- $Date::PeriodParser::TestTime = $base = 1018674096; # eliminate "used only once" warning
+ # Set the base time we use for tests (Fri Apr 12 22:01:36 2002)
+ $Date::PeriodParser::TestTime = $base =
+ timelocal( '36', '1', '22', '12', '3', '102' );
}
sub slt { scalar localtime timelocal @_ }
sub sl { scalar localtime shift }
+sub tl { timelocal @_ }
my ($s, $mn, $h, $d, $m, $y, $wd, $yd, $dst) = localtime($base);
- # Fri Apr 12 22:01:36 2002
+
%tests = (
- "round about now" => [ sl(1018673796), sl(1018674396) ],
- # Fri Apr 12 21:56:36 2002,
+ "round about now" => [ sl( tl( '36', '56', '21', '12', '3', '102' ) ),
+ sl( tl( '36', '06', '22', '12', '3', '102' ) )
+ ],
+ # Fri Apr 12 21:56:36 2002
# Fri Apr 12 22:06:36 2002
"roughly yesterday afternoon"
- => [sl(1018549800), sl(1018580400)],
+ => [ sl( tl( '00', '30', '11', '11', '3', '102' ) ),
+ sl( tl( '00', '00', '20', '11', '3', '102' ) )
+ ],
# Thu Apr 11 11:30:00 2002
# Thu Apr 11 20:00:00 2002
"around the morning of the day before yesterday"
- => [sl(1018414800), sl(1018472400)],
+ => [ sl( tl( '00', '00', '22', '9', '3', '102' ) ),
+ sl( tl( '00', '00', '14', '10', '3', '102' ) )
+ ],
# Tue Apr 9 22:00:00 2002
# Wed Apr 10 14:00:00 2002
- "roughly eleven days ago" => [ sl(1017518400), sl(1017863999) ],
+ "roughly eleven days ago" => [ sl( tl( '00', '00', '12', '30', '2', '102' ) ),
+ sl( tl( '59', '59', '11', '3', '3', '102' ) )
+ ],
# Sat Mar 30 12:00:00 2002
# Wed Apr 3 11:59:59 2002
);