Skip to content

Commit

Permalink
🧹🛑 standardize time around UTC
Browse files Browse the repository at this point in the history
we do not store timezones anywhere in our datatypes, so having any type of location attached leads to more problems than good right now

Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus committed Sep 18, 2023
1 parent 46cd566 commit d64d6ba
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions llx/builtin_simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ func timePlusTimeV2(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64) (
return TimeData(DurationToTime(sum))
}

return TimeData(time.Unix(sum, 0))
return TimeData(time.Unix(sum, 0).UTC())
})
}

Expand Down Expand Up @@ -2288,7 +2288,7 @@ func TimeToDuration(t *time.Time) int64 {

// DurationToTime takes a duration in seconds and turns it into a time object
func DurationToTime(i int64) time.Time {
return time.Unix(i+zeroTimeOffset, 0)
return time.Unix(i+zeroTimeOffset, 0).UTC()
}

func timeSecondsV2(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64) (*RawData, uint64, error) {
Expand Down
2 changes: 1 addition & 1 deletion llx/byte_conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ func bytes2float(b []byte) float64 {
func bytes2time(b []byte) time.Time {
secs := int64(binary.LittleEndian.Uint64(b[0:8]))
nanos := int64(binary.LittleEndian.Uint32(b[8:]))
return time.Unix(secs, nanos)
return time.Unix(secs, nanos).UTC()
}
3 changes: 1 addition & 2 deletions providers/core/resources/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ func (x *mqlTime) day() (*time.Time, error) {
}

func (x *mqlTime) today() (*time.Time, error) {
now := time.Now()
now := time.Now().UTC()
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())

return &today, nil
}

Expand Down
5 changes: 3 additions & 2 deletions providers/core/resources/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ func TestTimeParsing(t *testing.T) {
}

func TestTime_Methods(t *testing.T) {
now := time.Now()
now := time.Now().UTC()
today, _ := time.ParseInLocation("2006-01-02", now.Format("2006-01-02"), now.Location())
tomorrow := today.Add(24 * time.Hour)
today = today.UTC()
tomorrow := today.Add(24 * time.Hour).UTC()

x := testutils.InitTester(testutils.LinuxMock())
x.TestSimple(t, []testutils.SimpleTest{
Expand Down

0 comments on commit d64d6ba

Please sign in to comment.