Skip to content

Commit 82db164

Browse files
committed
Merge branch 'fix-date-reading' of github.com:zeripath/go-git into pr-1291
2 parents 17dbd88 + 6b25f85 commit 82db164

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ require (
2727
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0
2828
gopkg.in/warnings.v0 v0.1.2 // indirect
2929
)
30+
31+
go 1.13

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
1818
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
1919
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
2020
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
21+
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
2122
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
2223
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
2324
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
@@ -77,6 +78,7 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qq
7778
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7879
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
7980
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
81+
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
8082
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
8183
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
8284
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=

plumbing/object/object.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,19 @@ func (s *Signature) decodeTimeAndTimeZone(b []byte) {
138138
return
139139
}
140140

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]))
147-
if err != nil {
141+
timezone := string(b[tzStart : tzStart+timeZoneLength])
142+
tzhours, err1 := strconv.ParseInt(timezone[0:3], 10, 64)
143+
tzmins, err2 := strconv.ParseInt(timezone[3:], 10, 64)
144+
if err1 != nil || err2 != nil {
148145
return
149146
}
147+
if tzhours < 0 {
148+
tzmins *= -1
149+
}
150+
151+
tz := time.FixedZone("", int(tzhours*60*60+tzmins*60))
150152

151-
s.When = s.When.In(tl.Location())
153+
s.When = s.When.In(tz)
152154
}
153155

154156
func (s *Signature) encodeTimeAndTimeZone(w io.Writer) error {

0 commit comments

Comments
 (0)