aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-03-31 15:19:36 +0200
committerGitHub <noreply@github.com>2017-03-31 15:19:36 +0200
commit31a249d0d5b71bc0f374d3297247d89808263a8b (patch)
tree45e8f78f46d9ba0dea18bf14331a5c74b79b97cb /plumbing
parente512b0280d2747249acecdd8ba33b2ec80d0f364 (diff)
parentbdb72deddcc0b1c1f4eb71acb26da01c2e15fb79 (diff)
downloadgo-git-31a249d0d5b71bc0f374d3297247d89808263a8b.tar.gz
Merge pull request #320 from lupine/318-fix-timezone-parsing
Work around a Go bug when parsing timezones
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/object/object.go7
1 files changed, 6 insertions, 1 deletions
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
}