Skip to content

Commit 569276f

Browse files
authored
feat: Use RFC 3339, more lax datetime parsing (#122)
* feat: use more lax datetime parsing * chore: Update Go version
1 parent 49f16fc commit 569276f

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

.github/workflows/go.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@ on:
66
pull_request:
77

88
jobs:
9-
109
build:
1110
if: github.event.pull_request.draft == false
1211
name: Build
1312
runs-on: ubuntu-latest
14-
steps:
1513

14+
strategy:
15+
max-parallel: 2
16+
matrix:
17+
go-version:
18+
- stable
19+
- oldstable
20+
21+
steps:
1622
- name: Set up Go 1.x
1723
uses: actions/setup-go@v5
1824
with:
19-
go-version: '1.19'
25+
go-version: ${{ matrix.go-version }}
2026
id: go
2127

2228
- name: Check out code into the Go module directory

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-go@v5
1818
with:
19-
go-version: 1.19
19+
go-version: stable
2020
- name: golangci-lint
2121
uses: golangci/[email protected]
2222
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- run: git fetch --force --tags
2020
- uses: actions/setup-go@v5
2121
with:
22-
go-version: 1.19
22+
go-version: stable
2323
cache: true
2424
- uses: goreleaser/goreleaser-action@v5
2525
with:

flagengine/utils/time.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ package utils
33
import (
44
"strings"
55
"time"
6-
)
76

8-
const iso8601 = "2006-01-02T15:04:05.999999"
7+
"github.com/itlightning/dateparse"
8+
)
99

1010
type ISOTime struct {
1111
time.Time
1212
}
1313

1414
func (i *ISOTime) UnmarshalJSON(bytes []byte) (err error) {
15-
i.Time, err = time.Parse(iso8601, strings.Trim(string(bytes), `"`))
15+
i.Time, err = dateparse.ParseAny(strings.Trim(string(bytes), `"`))
1616
return
1717
}
1818

1919
func (i *ISOTime) MarshalJSON() ([]byte, error) {
20-
return []byte(`"` + i.Time.Format(iso8601) + `"`), nil
20+
return []byte(`"` + i.Time.Format(time.RFC3339) + `"`), nil
2121
}

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ require (
99
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
1010
)
1111

12+
require github.com/itlightning/dateparse v0.2.0
13+
1214
require (
1315
github.com/davecgh/go-spew v1.1.1 // indirect
1416
github.com/pmezard/go-difflib v1.0.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
66
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7+
github.com/itlightning/dateparse v0.2.0 h1:eOYLGZORnHweKdTZGOVjDXHhOwMQTNdP4g6+ErgPyeg=
8+
github.com/itlightning/dateparse v0.2.0/go.mod h1:W2PH6/Sq+PuJJ6JUgx2nau+ew1KLGXwoGP1A240x204=
79
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
810
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
911
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=

0 commit comments

Comments
 (0)