Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Nov 14, 2024
1 parent 6294626 commit b239ef0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/typing/ext/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions lib/typing/ext/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib/typing/ext/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b239ef0

Please sign in to comment.