diff --git a/.travis.yml b/.travis.yml index f5bc650..8bffb90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,39 +1,39 @@ language: go -matrix: + +go: + - 1.2.x + - 1.6.x + - 1.9.x + - 1.10.x + - 1.11.x + - 1.12.x + - 1.14.x + - tip + +os: + - linux + +arch: + - amd64 + +dist: xenial + +env: + - GOARCH=amd64 + +jobs: include: - - go: 1.2.x - env: GOOS=linux GOARCH=amd64 - - go: 1.2.x - env: GOOS=linux GOARCH=386 - - go: 1.2.x - env: GOOS=windows GOARCH=amd64 - - go: 1.2.x - env: GOOS=windows GOARCH=386 - - go: 1.3.x - - go: 1.4.x - - go: 1.5.x - - go: 1.6.x - - go: 1.7.x - - go: 1.8.x - - go: 1.9.x - - go: 1.10.x - - go: 1.11.x - - go: 1.12.x - - go: 1.13.x - - go: 1.14.x - env: GOOS=linux GOARCH=amd64 - - go: 1.14.x - env: GOOS=linux GOARCH=386 - - go: 1.14.x - env: GOOS=windows GOARCH=amd64 - - go: 1.14.x - env: GOOS=windows GOARCH=386 - - go: tip -go_import_path: gopkg.in/asn-ber.v1 -install: - - go list -f '{{range .Imports}}{{.}} {{end}}' ./... | xargs go get -v - - go list -f '{{range .TestImports}}{{.}} {{end}}' ./... | xargs go get -v - - go get code.google.com/p/go.tools/cmd/cover || go get golang.org/x/tools/cmd/cover - - go build -v ./... + - os: windows + go: 1.14.x + - os: osx + go: 1.14.x + - os: linux + go: 1.14.x + arch: arm64 + - os: linux + go: 1.14.x + env: + - GOARCH=386 + script: - go test -v -cover ./... || go test -v ./... diff --git a/generalizedTime.go b/generalizedTime.go index 924e8f1..51215f0 100644 --- a/generalizedTime.go +++ b/generalizedTime.go @@ -13,6 +13,10 @@ var ErrInvalidTimeFormat = errors.New("invalid time format") var zeroTime = time.Time{} +// ParseGeneralizedTime parses a string value and if it conforms to +// GeneralizedTime[^0] format, will return a time.Time for that value. +// +// [^0]: https://www.itu.int/rec/T-REC-X.690-201508-I/en Section 11.7 func ParseGeneralizedTime(v []byte) (time.Time, error) { var format string var fract time.Duration @@ -59,10 +63,10 @@ func ParseGeneralizedTime(v []byte) (time.Time, error) { tzIndex = dot if dot == 10 { - fract = time.Duration(int(f * float64(time.Hour))) + fract = time.Duration(int64(f * float64(time.Hour))) format = `2006010215Z` } else { - fract = time.Duration(int(f * float64(time.Minute))) + fract = time.Duration(int64(f * float64(time.Minute))) format = `200601021504Z` }