From a4262bdbbe75e3238cb38738f08c70f94ec54e1d Mon Sep 17 00:00:00 2001 From: carlv-stripe <51128920+carlv-stripe@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:56:58 -0700 Subject: [PATCH 1/3] Update format_test.go Signed-off-by: Carl Vincent --- format_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format_test.go b/format_test.go index 5e06b47..525f19e 100644 --- a/format_test.go +++ b/format_test.go @@ -240,7 +240,7 @@ func TestDecodeDateTimeHook(t *testing.T) { }, { "invalid non empty datetime", - "2019-01-01", + "2019-01-01abc", }, } registry := NewFormats() From 2f7945a9abd966097dcaeb8b4ce6c320e6c218d4 Mon Sep 17 00:00:00 2001 From: carlv-stripe <51128920+carlv-stripe@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:58:07 -0700 Subject: [PATCH 2/3] Update time.go Signed-off-by: Carl Vincent --- time.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/time.go b/time.go index 9bef4c3..682235d 100644 --- a/time.go +++ b/time.go @@ -76,6 +76,8 @@ const ( ISO8601TimeWithReducedPrecisionLocaltime = "2006-01-02T15:04" // ISO8601TimeUniversalSortableDateTimePattern represents a ISO8601 universal sortable date time pattern. ISO8601TimeUniversalSortableDateTimePattern = "2006-01-02 15:04:05" + // short form of ISO8601TimeUniversalSortableDateTimePattern + ISO8601TimeUniversalSortableDateTimePatternShortForm = "2006-01-02" // DateTimePattern pattern to match for the date-time format from http://tools.ietf.org/html/rfc3339#section-5.6 DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$` ) @@ -84,7 +86,7 @@ var ( rxDateTime = regexp.MustCompile(DateTimePattern) // DateTimeFormats is the collection of formats used by ParseDateTime() - DateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime, ISO8601TimeUniversalSortableDateTimePattern} + DateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime, ISO8601TimeUniversalSortableDateTimePattern, ISO8601TimeUniversalSortableDateTimePatternShortForm} // MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds) MarshalFormat = RFC3339Millis From f514ed1add9606aac1d8d716d2222b9c80937ac0 Mon Sep 17 00:00:00 2001 From: carlv-stripe <51128920+carlv-stripe@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:58:27 -0700 Subject: [PATCH 3/3] Update time_test.go Signed-off-by: Carl Vincent --- time_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/time_test.go b/time_test.go index 67c3d48..c2babb1 100644 --- a/time_test.go +++ b/time_test.go @@ -33,6 +33,7 @@ var ( str string // its marshalled representation utcStr string // the marshaled representation as utc }{ + {[]byte("2014-12-15"), time.Date(2014, 12, 15, 0, 0, 0, 0, time.UTC), "2014-12-15T00:00:00.000Z", "2014-12-15T00:00:00.000Z"}, {[]byte("2014-12-15 08:00:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"}, {[]byte("2014-12-15T08:00:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"}, {[]byte("2014-12-15T08:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},