Skip to content

Commit ca05b5f

Browse files
committed
pkg/time: use UTC time zone for Unix and Parse
Change-Id: Ia38856c40bfca70620c7783d41ea3936a020b745 Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2726 Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 6bf3697 commit ca05b5f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/time/time.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func Parse(layout, value string) (string, error) {
189189
if err != nil {
190190
return "", err
191191
}
192-
return t.Format(time.RFC3339Nano), nil
192+
return t.UTC().Format(time.RFC3339Nano), nil
193193
}
194194

195195
// Unix returns the local Time corresponding to the given Unix time,
@@ -199,5 +199,5 @@ func Parse(layout, value string) (string, error) {
199199
// value is 1<<63-1 (the largest int64 value).
200200
func Unix(sec int64, nsec int64) string {
201201
t := time.Unix(sec, nsec)
202-
return t.Format(time.RFC3339Nano)
202+
return t.UTC().Format(time.RFC3339Nano)
203203
}

pkg/time/time_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ func TestUnix(t *testing.T) {
102102
nano int64
103103
want string
104104
}{
105-
{0, 0, "1970-01-01T01:00:00+01:00"},
106-
{1500000000, 123456, "2017-07-14T04:40:00.000123456+02:00"},
105+
{0, 0, "1970-01-01T00:00:00Z"},
106+
{1500000000, 123456, "2017-07-14T02:40:00.000123456Z"},
107107
}
108108

109109
for _, tc := range valid {

0 commit comments

Comments
 (0)