From 38408f7b9765c44b1a66b1e70afa4bf2783e3317 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Tue, 22 Oct 2024 13:27:51 -0700 Subject: [PATCH] Function rename. --- clients/shared/default_value_test.go | 2 +- lib/typing/ext/parse.go | 5 +++-- lib/typing/ext/parse_test.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/clients/shared/default_value_test.go b/clients/shared/default_value_test.go index bde1d165f..32495e414 100644 --- a/clients/shared/default_value_test.go +++ b/clients/shared/default_value_test.go @@ -25,7 +25,7 @@ var dialects = []sql.Dialect{ func TestColumn_DefaultValue(t *testing.T) { birthday := time.Date(2022, time.September, 6, 3, 19, 24, 942000000, time.UTC) - birthdayExtDateTime, err := ext.ParseExtendedDateTime(birthday.Format(ext.ISO8601), ext.TimestampTZKindType) + birthdayExtDateTime, err := ext.ParseDateTime(birthday.Format(ext.ISO8601), ext.TimestampTZKindType) assert.NoError(t, err) // date diff --git a/lib/typing/ext/parse.go b/lib/typing/ext/parse.go index 9fbefdb85..2b8439554 100644 --- a/lib/typing/ext/parse.go +++ b/lib/typing/ext/parse.go @@ -29,7 +29,7 @@ func ParseFromInterface(val any, kindType ExtendedTimeKindType) (time.Time, erro case *ExtendedTime: return convertedVal.GetTime(), nil case string: - ts, err := ParseExtendedDateTime(convertedVal, kindType) + ts, err := ParseDateTime(convertedVal, kindType) if err != nil { return time.Time{}, fmt.Errorf("failed to parse colVal: %q, err: %w", val, err) } @@ -40,7 +40,8 @@ func ParseFromInterface(val any, kindType ExtendedTimeKindType) (time.Time, erro } } -func ParseExtendedDateTime(value string, kindType ExtendedTimeKindType) (time.Time, error) { +func ParseDateTime(value string, kindType ExtendedTimeKindType) (time.Time, error) { + // TODO: Support TimestampNTZKindType switch kindType { case TimestampTZKindType: return parseDateTime(value) diff --git a/lib/typing/ext/parse_test.go b/lib/typing/ext/parse_test.go index ce66ed58f..423b8fdf7 100644 --- a/lib/typing/ext/parse_test.go +++ b/lib/typing/ext/parse_test.go @@ -88,7 +88,7 @@ func TestParseFromInterfaceDate(t *testing.T) { func TestParseExtendedDateTime_Timestamp(t *testing.T) { tsString := "2023-04-24T17:29:05.69944Z" - extTime, err := ParseExtendedDateTime(tsString, TimestampTZKindType) + extTime, err := ParseDateTime(tsString, TimestampTZKindType) assert.NoError(t, err) assert.Equal(t, "2023-04-24T17:29:05.69944Z", extTime.Format(time.RFC3339Nano)) } @@ -98,7 +98,7 @@ func TestTimeLayout(t *testing.T) { for _, supportedFormat := range SupportedTimeFormats { parsedTsString := ts.Format(supportedFormat) - extTime, err := ParseExtendedDateTime(parsedTsString, TimeKindType) + extTime, err := ParseDateTime(parsedTsString, TimeKindType) assert.NoError(t, err) assert.Equal(t, parsedTsString, extTime.Format(supportedFormat)) }