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

Commit 31a249d

Browse files
authored
Merge pull request #320 from lupine/318-fix-timezone-parsing
Work around a Go bug when parsing timezones
2 parents e512b02 + bdb72de commit 31a249d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plumbing/object/object.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ func (s *Signature) decodeTimeAndTimeZone(b []byte) {
138138
return
139139
}
140140

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

0 commit comments

Comments
 (0)