Skip to content

Commit 940d7ce

Browse files
authored
29 generalized time bug (#30)
* Fix #29 :: ParseGeneralizedTime should explicitly use int64 * Add missing comment doc * Travis Updates * Update travis test matrix
1 parent 4f900ee commit 940d7ce

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

.travis.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
language: go
2-
matrix:
2+
3+
go:
4+
- 1.2.x
5+
- 1.6.x
6+
- 1.9.x
7+
- 1.10.x
8+
- 1.11.x
9+
- 1.12.x
10+
- 1.14.x
11+
- tip
12+
13+
os:
14+
- linux
15+
16+
arch:
17+
- amd64
18+
19+
dist: xenial
20+
21+
env:
22+
- GOARCH=amd64
23+
24+
jobs:
325
include:
4-
- go: 1.2.x
5-
env: GOOS=linux GOARCH=amd64
6-
- go: 1.2.x
7-
env: GOOS=linux GOARCH=386
8-
- go: 1.2.x
9-
env: GOOS=windows GOARCH=amd64
10-
- go: 1.2.x
11-
env: GOOS=windows GOARCH=386
12-
- go: 1.3.x
13-
- go: 1.4.x
14-
- go: 1.5.x
15-
- go: 1.6.x
16-
- go: 1.7.x
17-
- go: 1.8.x
18-
- go: 1.9.x
19-
- go: 1.10.x
20-
- go: 1.11.x
21-
- go: 1.12.x
22-
- go: 1.13.x
23-
- go: 1.14.x
24-
env: GOOS=linux GOARCH=amd64
25-
- go: 1.14.x
26-
env: GOOS=linux GOARCH=386
27-
- go: 1.14.x
28-
env: GOOS=windows GOARCH=amd64
29-
- go: 1.14.x
30-
env: GOOS=windows GOARCH=386
31-
- go: tip
32-
go_import_path: gopkg.in/asn-ber.v1
33-
install:
34-
- go list -f '{{range .Imports}}{{.}} {{end}}' ./... | xargs go get -v
35-
- go list -f '{{range .TestImports}}{{.}} {{end}}' ./... | xargs go get -v
36-
- go get code.google.com/p/go.tools/cmd/cover || go get golang.org/x/tools/cmd/cover
37-
- go build -v ./...
26+
- os: windows
27+
go: 1.14.x
28+
- os: osx
29+
go: 1.14.x
30+
- os: linux
31+
go: 1.14.x
32+
arch: arm64
33+
- os: linux
34+
go: 1.14.x
35+
env:
36+
- GOARCH=386
37+
3838
script:
3939
- go test -v -cover ./... || go test -v ./...

generalizedTime.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ var ErrInvalidTimeFormat = errors.New("invalid time format")
1313

1414
var zeroTime = time.Time{}
1515

16+
// ParseGeneralizedTime parses a string value and if it conforms to
17+
// GeneralizedTime[^0] format, will return a time.Time for that value.
18+
//
19+
// [^0]: https://www.itu.int/rec/T-REC-X.690-201508-I/en Section 11.7
1620
func ParseGeneralizedTime(v []byte) (time.Time, error) {
1721
var format string
1822
var fract time.Duration
@@ -59,10 +63,10 @@ func ParseGeneralizedTime(v []byte) (time.Time, error) {
5963
tzIndex = dot
6064

6165
if dot == 10 {
62-
fract = time.Duration(int(f * float64(time.Hour)))
66+
fract = time.Duration(int64(f * float64(time.Hour)))
6367
format = `2006010215Z`
6468
} else {
65-
fract = time.Duration(int(f * float64(time.Minute)))
69+
fract = time.Duration(int64(f * float64(time.Minute)))
6670
format = `200601021504Z`
6771
}
6872

0 commit comments

Comments
 (0)