Skip to content

Commit

Permalink
Use third-party library to convert time.Time to UTC string
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyisaev2 committed Dec 19, 2024
1 parent 5cd13fc commit b1b683c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1,246 deletions.
6 changes: 4 additions & 2 deletions app/server/conversion/converters_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"time"

"github.com/phuslu/fasttime"

"github.com/ydb-platform/fq-connector-go/common"
)

Expand Down Expand Up @@ -137,11 +139,11 @@ func (timestampToStringConverterUTC) Convert(in *time.Time) (string, error) {
// ClickHouse - 1 nanosecond (10^-9 s)
// Oracle - 1 nanosecond (10^-9 s)
// Trailing zeros are omitted
return in.UTC().Format("2006-01-02T15:04:05.999999999Z"), nil
return fasttime.Strftime("%Y-%m-%dT%H:%M:%S.%N%:z", in.UTC()), nil
}

type timestampToStringConverterNaive struct{}

func (timestampToStringConverterNaive) Convert(in *time.Time) (string, error) {
return in.Format("2006-01-02T15:04:05.999999999"), nil
return fasttime.Strftime("%Y-%m-%dT%H:%M:%S.%N%:z", *in), nil
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ require (
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/phuslu/fasttime v1.0.2
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
Expand Down
Loading

0 comments on commit b1b683c

Please sign in to comment.