Skip to content

Commit

Permalink
29 generalized time bug (#30)
Browse files Browse the repository at this point in the history
* Fix #29 :: ParseGeneralizedTime should explicitly use int64

* Add missing comment doc

* Travis Updates

* Update travis test matrix
  • Loading branch information
johnweldon authored Jun 27, 2020
1 parent 4f900ee commit 940d7ce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
70 changes: 35 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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 ./...
8 changes: 6 additions & 2 deletions generalizedTime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
}

Expand Down

0 comments on commit 940d7ce

Please sign in to comment.