Commit 02786d26 authored by Adam Langley's avatar Adam Langley

time: fix parsing of minutes in time zones.

R=r
CC=golang-dev
https://golang.org/cl/1830041
parent dcd9d785
......@@ -522,7 +522,7 @@ func Parse(alayout, avalue string) (*Time, os.Error) {
}
var hr, min int
hr, err = strconv.Atoi(hh)
if err != nil {
if err == nil {
min, err = strconv.Atoi(mm)
}
t.ZoneOffset = (hr*60 + min) * 60 // offset is in seconds
......
......@@ -303,6 +303,17 @@ func TestMissingZone(t *testing.T) {
}
}
func TestMinutesInTimeZone(t *testing.T) {
time, err := Parse(RubyDate, "Mon Jan 02 15:04:05 +0123 2006")
if err != nil {
t.Fatal("error parsing date:", err)
}
expected := (1*60 + 23) * 60
if time.ZoneOffset != expected {
t.Errorf("ZoneOffset incorrect, expected %d got %d", expected, time.ZoneOffset)
}
}
func BenchmarkSeconds(b *testing.B) {
for i := 0; i < b.N; i++ {
Seconds()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment