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:
parent
40d241b138
commit
7904dd3405
1 changed files with 7 additions and 5 deletions
10
db/tz-erl
10
db/tz-erl
|
@ -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 {
|
sub offset_minutes {
|
||||||
my ($off, $adj) = @_;
|
my ($off, $adj) = @_;
|
||||||
|
|
||||||
my $convert_offset = sub {
|
my $convert_offset = sub {
|
||||||
my $m = $_[0];
|
$_[0] =~ m/^([\+\-]?)(\d+)(?::(\d+))?$/
|
||||||
if ($m =~ m/^([\+\-]?)(?:(\d+):)?(\d+)$/) {
|
or die "offset \"$_[0]\" did not match";
|
||||||
$m = (defined $2 ? $2 : 0) * MPH + $3;
|
my $m = $2 * MPH;
|
||||||
|
if (defined $3) { $m += $3; }
|
||||||
if ($1 eq '-') { $m = -$m; }
|
if ($1 eq '-') { $m = -$m; }
|
||||||
}
|
|
||||||
return $m;
|
return $m;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue