Skip to content

Commit

Permalink
feat(proto): use time.Local by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Jun 18, 2022
1 parent dc5c270 commit 2eb6a46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions proto/col_datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func (c *ColDateTime) Infer(t ColumnType) error {

func (c ColDateTime) loc() *time.Location {
if c.Location == nil {
return time.UTC
// Defaulting to local timezone (not UTC).
return time.Local
}
return c.Location
}
Expand All @@ -61,7 +62,7 @@ func (c ColDateTime) Row(i int) time.Time {
}

func (c *ColDateTime) Append(v time.Time) {
c.Data = append(c.Data, ToDateTime(v.In(c.loc())))
c.Data = append(c.Data, ToDateTime(v))
}

// LowCardinality returns LowCardinality for Enum8 .
Expand Down
12 changes: 8 additions & 4 deletions proto/col_datetime64.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ func (c *ColDateTime64) Infer(t ColumnType) error {
}

func (c ColDateTime64) Row(i int) time.Time {
loc := time.UTC
if c.Location != nil {
loc = c.Location
return c.Data[i].Time(c.Precision).In(c.loc())
}

func (c ColDateTime64) loc() *time.Location {
if c.Location == nil {
// Defaulting to local timezone (not UTC).
return time.Local
}
return c.Data[i].Time(c.Precision).In(loc)
return c.Location
}

func (c *ColDateTime64) Append(v time.Time) {
Expand Down

0 comments on commit 2eb6a46

Please sign in to comment.