From b239ef030c6d1c2e26565b11bbb0f5e7ed201b9e Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Thu, 14 Nov 2024 12:45:11 -0800 Subject: [PATCH] Clean up. --- lib/typing/ext/parse.go | 5 ++++- lib/typing/ext/parse_test.go | 6 ++++++ lib/typing/ext/variables.go | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/typing/ext/parse.go b/lib/typing/ext/parse.go index f9d467688..88c3b9383 100644 --- a/lib/typing/ext/parse.go +++ b/lib/typing/ext/parse.go @@ -101,9 +101,12 @@ func ParseTimestampTZFromAny(val any) (time.Time, error) { func parseTimestampTZ(value string) (time.Time, error) { for _, supportedDateTimeLayout := range supportedDateTimeLayouts { - if ts, err := ParseTimeExactMatch(supportedDateTimeLayout, value); err == nil { + ts, err := ParseTimeExactMatch(supportedDateTimeLayout, value) + if err == nil { return ts, nil } + + fmt.Println("err", err, "value", value) } return time.Time{}, fmt.Errorf("unsupported value: %q", value) diff --git a/lib/typing/ext/parse_test.go b/lib/typing/ext/parse_test.go index 237ac6a56..e15c0a548 100644 --- a/lib/typing/ext/parse_test.go +++ b/lib/typing/ext/parse_test.go @@ -77,6 +77,12 @@ func TestParseTimestampTZFromAny(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "2024-09-19T16:05:18.630000002Z", value.Format(time.RFC3339Nano)) } + { + // Another string variant + value, err := ParseTimestampTZFromAny("2023-07-20T11:01:33.159+00:00") + assert.NoError(t, err) + assert.Equal(t, "2023-07-20T11:01:33.159Z", value.Format(time.RFC3339Nano)) + } } func TestParseTimestampNTZFromAny(t *testing.T) { diff --git a/lib/typing/ext/variables.go b/lib/typing/ext/variables.go index 80874bee9..f120f308a 100644 --- a/lib/typing/ext/variables.go +++ b/lib/typing/ext/variables.go @@ -16,6 +16,7 @@ var supportedDateTimeLayouts = []string{ RFC3339Nanosecond, time.RFC3339Nano, // Others + "2006-01-02T15:04:05.999999999-07:00", time.Layout, time.ANSIC, time.UnixDate,