tz-erl: Fix offset_minutes($o) when $o just digits is hours offset.

Previouly when offset_minute's argument was just digits (for example,
"+2" instead of "+2:00"), the argument was incorrectly interpreted as
minutes when it should be as hours.
This commit is contained in:
David Hull 2015-11-21 20:56:10 +00:00
parent 40d241b138
commit 7904dd3405

View file

@ -145,15 +145,17 @@ sub process_data {
}
}
# Converts an offset in the format "[+-]?HH:MM" or "[+-]?HH" into minutes.
# For example, "2:00" -> 120, "-0:30" -> -30, "+5" -> 300.
sub offset_minutes {
my ($off, $adj) = @_;
my $convert_offset = sub {
my $m = $_[0];
if ($m =~ m/^([\+\-]?)(?:(\d+):)?(\d+)$/) {
$m = (defined $2 ? $2 : 0) * MPH + $3;
if ($1 eq '-') { $m = -$m; }
}
$_[0] =~ m/^([\+\-]?)(\d+)(?::(\d+))?$/
or die "offset \"$_[0]\" did not match";
my $m = $2 * MPH;
if (defined $3) { $m += $3; }
if ($1 eq '-') { $m = -$m; }
return $m;
};