Skip to content

Commit

Permalink
feat: use more lax datetime parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Apr 4, 2024
1 parent 49f16fc commit c4a719d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flagengine/utils/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package utils
import (
"strings"
"time"
)

const iso8601 = "2006-01-02T15:04:05.999999"
"github.com/nav-inc/datetime"
)

type ISOTime struct {
time.Time
}

func (i *ISOTime) UnmarshalJSON(bytes []byte) (err error) {
i.Time, err = time.Parse(iso8601, strings.Trim(string(bytes), `"`))
i.Time, err = datetime.Parse(strings.Trim(string(bytes), `"`), time.UTC)
return
}

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

0 comments on commit c4a719d

Please sign in to comment.