Skip to content

Commit

Permalink
Function rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 22, 2024
1 parent 27d3d2b commit 38408f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clients/shared/default_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/typing/ext/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/typing/ext/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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))
}
Expand Down

0 comments on commit 38408f7

Please sign in to comment.