Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Work around a Go bug when parsing timezones #320

Merged
merged 1 commit into from
Mar 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion plumbing/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ func (s *Signature) decodeTimeAndTimeZone(b []byte) {
return
}

tl, err := time.Parse("-0700", string(b[tzStart:tzStart+timeZoneLength]))
// Include a dummy year in this time.Parse() call to avoid a bug in Go:
// https://github.com/golang/go/issues/19750
//
// Parsing the timezone with no other details causes the tl.Location() call
// below to return time.Local instead of the parsed zone in some cases
tl, err := time.Parse("2006 -0700", "1970 "+string(b[tzStart:tzStart+timeZoneLength]))
if err != nil {
return
}
Expand Down