diff --git a/bigquery/value.go b/bigquery/value.go index ec6c26996c86..34070d033f99 100644 --- a/bigquery/value.go +++ b/bigquery/value.go @@ -958,7 +958,7 @@ func convertBasicType(val string, typ FieldType) (Value, error) { if err != nil { return nil, err } - return time.UnixMicro(i), nil + return time.UnixMicro(i).UTC(), nil case DateFieldType: return civil.ParseDate(val) case TimeFieldType: diff --git a/bigquery/value_test.go b/bigquery/value_test.go index d6db62b8fd9d..57c3429d13e3 100644 --- a/bigquery/value_test.go +++ b/bigquery/value_test.go @@ -95,6 +95,11 @@ func TestConvertTime(t *testing.T) { t.Errorf("#%d: got:\n%v\nwant:\n%v", i, g, w) } } + // Ensure that the times are returned in UTC timezone. + // https://github.com/googleapis/google-cloud-go/issues/9407 + if gotTZ := got[0].(time.Time).Location(); gotTZ != time.UTC { + t.Errorf("expected time zone UTC: got:\n%v", gotTZ) + } } func TestConvertSmallTimes(t *testing.T) {