mirror of
https://github.com/golang/go
synced 2024-11-22 05:24:39 -07:00
time: fix parsing of minutes in time zones.
R=r CC=golang-dev https://golang.org/cl/1830041
This commit is contained in:
parent
dcd9d78549
commit
02786d263c
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user