Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jul 25, 2024
1 parent 0aab849 commit b548b49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 7 additions & 1 deletion lib/debezium/converters/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func ConvertDateTimeWithTimezone(value any) (*ext.ExtendedTime, error) {
return nil, fmt.Errorf("failed to parse %q, err: %w", dtString, err)
}

var SupportedTimeWithTimezoneFormats = []string{
"15:04:05Z", // w/o fractional seconds
"15:04:05.000Z", // ms
"15:04:05.000000Z", // microseconds
}

func ConvertTimeWithTimezone(value any) (*ext.ExtendedTime, error) {
valString, isOk := value.(string)
if !isOk {
Expand All @@ -43,7 +49,7 @@ func ConvertTimeWithTimezone(value any) (*ext.ExtendedTime, error) {

var err error
var ts time.Time
for _, supportedTimeFormat := range ext.SupportedTimeWithTimezoneFormats {
for _, supportedTimeFormat := range SupportedTimeWithTimezoneFormats {
ts, err = ext.ParseTimeExactMatch(supportedTimeFormat, valString)
if err == nil {
return ext.NewExtendedTime(ts, ext.TimeKindType, supportedTimeFormat), nil
Expand Down
6 changes: 0 additions & 6 deletions lib/typing/ext/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ var SupportedTimeFormatsLegacy = []string{
AdditionalTimeFormat,
}

var SupportedTimeWithTimezoneFormats = []string{
"15:04:05Z", // w/o fractional seconds
"15:04:05.000Z", // ms
"15:04:05.000000Z", // microseconds
}

func NewUTCTime(layout string) string {
return time.Now().UTC().Format(layout)
}

0 comments on commit b548b49

Please sign in to comment.