aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-03-10 00:01:32 +0100
committerGitHub <noreply@github.com>2020-03-10 00:01:32 +0100
commit87d3d897d903af9cdd5cf500fd36d3533235fc02 (patch)
tree448a77a14c161e2ebee2434c76768ecc1947c503
parent18a858b38ca4197987a6da7058ab0397255fa82c (diff)
parent82db164e49e6f2c1b501ca64ab236399df594e8f (diff)
downloadgo-git-87d3d897d903af9cdd5cf500fd36d3533235fc02.tar.gz
Merge pull request #2 from go-git/pr-1291
plumbing: object, fix date reading
-rw-r--r--go.mod2
-rw-r--r--plumbing/object/object.go18
2 files changed, 12 insertions, 8 deletions
diff --git a/go.mod b/go.mod
index 6f8b3d2..31907a6 100644
--- a/go.mod
+++ b/go.mod
@@ -27,3 +27,5 @@ require (
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0
gopkg.in/warnings.v0 v0.1.2 // indirect
)
+
+go 1.13
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 {