diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-03-09 23:12:03 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2020-03-09 23:12:03 +0100 |
commit | 82db164e49e6f2c1b501ca64ab236399df594e8f (patch) | |
tree | 906bcc6d8dfaaf55477ba57853efea0abf59eac4 /plumbing/object/object.go | |
parent | 17dbd886616f82be2a59c0d02fd93d3d69f2392c (diff) | |
parent | 6b25f8506c2ef719f89e728aba652f3c6e3ca6e6 (diff) | |
download | go-git-82db164e49e6f2c1b501ca64ab236399df594e8f.tar.gz |
Merge branch 'fix-date-reading' of github.com:zeripath/go-git into pr-1291
Diffstat (limited to 'plumbing/object/object.go')
-rw-r--r-- | plumbing/object/object.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/plumbing/object/object.go b/plumbing/object/object.go index e960e50..c48a18d 100644 --- a/plumbing/object/object.go +++ b/plumbing/object/object.go @@ -138,17 +138,19 @@ func (s *Signature) decodeTimeAndTimeZone(b []byte) { return } - // 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 { + timezone := string(b[tzStart : tzStart+timeZoneLength]) + tzhours, err1 := strconv.ParseInt(timezone[0:3], 10, 64) + tzmins, err2 := strconv.ParseInt(timezone[3:], 10, 64) + if err1 != nil || err2 != nil { return } + if tzhours < 0 { + tzmins *= -1 + } + + tz := time.FixedZone("", int(tzhours*60*60+tzmins*60)) - s.When = s.When.In(tl.Location()) + s.When = s.When.In(tz) } func (s *Signature) encodeTimeAndTimeZone(w io.Writer) error { |