Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 24, 2024
1 parent 9df8521 commit 443791f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/debezium/converters/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (m MicroTime) Convert(value any) (any, error) {
type ZonedTimestamp struct{}

func (ZonedTimestamp) layout() string {
return "2006-01-02T15:04:05.999999999Z"
return ext.RFC3339
}

func (z ZonedTimestamp) ToKindDetails() (typing.KindDetails, error) {
Expand Down
8 changes: 8 additions & 0 deletions lib/debezium/converters/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ func TestZonedTimestamp_Convert(t *testing.T) {
assert.Equal(t, expectedExtTime, val.(*ext.ExtendedTime))
assert.Equal(t, "2025-09-13T00:00:00.123456789Z", val.(*ext.ExtendedTime).GetTime().Format(ZonedTimestamp{}.layout()))
}
{
// Testing TZ offset
val, err := ZonedTimestamp{}.Convert("2025-09-13T00:00:00.123456789+07:00")
assert.NoError(t, err)

assert.Equal(t, time.Date(2025, time.September, 13, 0, 0, 0, 123456789, time.FixedZone("", 7*60*60)), val.(*ext.ExtendedTime).GetTime())
assert.Equal(t, "2025-09-13T00:00:00.123456789+07:00", val.(*ext.ExtendedTime).GetTime().Format(ZonedTimestamp{}.layout()))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/debezium/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func TestField_ToKindDetails(t *testing.T) {
for _, dbzType := range []SupportedDebeziumType{ZonedTimestamp} {
kd, err := Field{DebeziumType: dbzType}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "2006-01-02T15:04:05.999999999Z"), kd)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ext.RFC3339), kd)
}
}
{
Expand Down
4 changes: 3 additions & 1 deletion lib/typing/ext/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const TimezoneOffsetFormat = "Z07:00"

// RFC3339 variants
const (
RFC3339NoTZ = "2006-01-02T15:04:05.999999999"
RFC3339NoTZ = "2006-01-02T15:04:05.999999999"
RFC3339 = "2006-01-02T15:04:05.999999999" + TimezoneOffsetFormat

RFC3339MillisecondUTC = "2006-01-02T15:04:05.000Z"
RFC3339MicrosecondUTC = "2006-01-02T15:04:05.000000Z"
RFC3339NanosecondUTC = "2006-01-02T15:04:05.000000000Z"
Expand Down

0 comments on commit 443791f

Please sign in to comment.