From bdb72deddcc0b1c1f4eb71acb26da01c2e15fb79 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Thu, 30 Mar 2017 19:28:15 +0100 Subject: Work around a Go bug when parsing timezones --- plumbing/object/object.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plumbing/object/object.go b/plumbing/object/object.go index 701145d..4b59aba 100644 --- a/plumbing/object/object.go +++ b/plumbing/object/object.go @@ -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 } -- cgit