From d64d6bac2004aea208738af1297cf70775ead0cb Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sun, 17 Sep 2023 23:44:05 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=F0=9F=9B=91=20standardize=20time?= =?UTF-8?q?=20around=20UTC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- llx/builtin_simple.go | 4 ++-- llx/byte_conversions.go | 2 +- providers/core/resources/time.go | 3 +-- providers/core/resources/time_test.go | 5 +++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/llx/builtin_simple.go b/llx/builtin_simple.go index ee50e0e867..303e1e924a 100644 --- a/llx/builtin_simple.go +++ b/llx/builtin_simple.go @@ -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()) }) } @@ -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) { diff --git a/llx/byte_conversions.go b/llx/byte_conversions.go index 127f7b65c6..bcba9b61f2 100644 --- a/llx/byte_conversions.go +++ b/llx/byte_conversions.go @@ -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() } diff --git a/providers/core/resources/time.go b/providers/core/resources/time.go index adb760b3f8..e77824e94f 100644 --- a/providers/core/resources/time.go +++ b/providers/core/resources/time.go @@ -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 } diff --git a/providers/core/resources/time_test.go b/providers/core/resources/time_test.go index 193e2aa2b1..c8cba6724f 100644 --- a/providers/core/resources/time_test.go +++ b/providers/core/resources/time_test.go @@ -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{