Subject: | Patch for DateTime::TimeZone::OlsonDB that may or may not be useful |
I ran into a curious problem while building an updated version of perl-DateTime for Fedora (multiple releases, 6 through 12). All of the tests would succeed in Fedora 10, 11, and 12, but a couple of tests would fail in anything older than 10. (I've attached a complete build log to show the test failures at the end.)
To make a long story short, I was able to get this to work by rewriting a small section of DateTime::TimeZone::OlsonDB (see attached patch). The code that triggered the failing call to DateTime->new() uses a pattern match but spreads out the use of $1, $2, and $3 across the block. I rewrote it to save these in local variables immediately, then use those variables instead of $1, $2, and $3. The tests then worked.
*Why* this is so, I cannot say. :-) It may be because the "broken" Fedora distros all have a version of Params::Validate older than 0.91; DateTime requires that, but my builds did not enforce it.
So do with this patch whatever you like; it may be moot.
To make a long story short, I was able to get this to work by rewriting a small section of DateTime::TimeZone::OlsonDB (see attached patch). The code that triggered the failing call to DateTime->new() uses a pattern match but spreads out the use of $1, $2, and $3 across the block. I rewrote it to save these in local variables immediately, then use those variables instead of $1, $2, and $3. The tests then worked.
*Why* this is so, I cannot say. :-) It may be because the "broken" Fedora distros all have a version of Params::Validate older than 0.91; DateTime requires that, but my builds did not enforce it.
So do with this patch whatever you like; it may be moot.
Subject: | bug.log.gz |
Message body not shown because it is not plain text.
Subject: | OlsonDB.pm.patch |
diff --git a/lib/DateTime/TimeZone/OlsonDB.pm b/lib/DateTime/TimeZone/OlsonDB.pm
index 021202b..2dbe23c 100644
--- a/lib/DateTime/TimeZone/OlsonDB.pm
+++ b/lib/DateTime/TimeZone/OlsonDB.pm
@@ -222,15 +222,18 @@ sub parse_day_spec
}
elsif ( $day =~ /^(\w\w\w)([><])=(\d\d?)$/ )
{
- my $dow = $DAYS{$1};
+ my ( $dow, $less_gt_than, $day ) = ( $1, $2, $3 );
+ $dow = $DAYS{$dow};
my $dt = DateTime->new( year => $year,
month => $month,
- day => $3,
+ day => $day,
time_zone => 'floating',
);
- my $dur = $2 eq '<' ? $MINUS_ONE_DAY_DUR : $PLUS_ONE_DAY_DUR;
+ my $dur = $less_gt_than eq '<'
+ ? $MINUS_ONE_DAY_DUR
+ : $PLUS_ONE_DAY_DUR;
while ( $dt->day_of_week != $dow )
{