Skip to content

moment assumes PST instead of UTC. Change moment to create object assuming UTC to stay consistent with BQ. #508

Merged
danieldeleo merged 13 commits intoGoogleCloudPlatform:masterfrom
mingjialiu:master
Sep 25, 2025
Merged

moment assumes PST instead of UTC. Change moment to create object assuming UTC to stay consistent with BQ. #508
danieldeleo merged 13 commits intoGoogleCloudPlatform:masterfrom
mingjialiu:master

Conversation

@mingjialiu
Copy link
Contributor

@mingjialiu mingjialiu commented Sep 15, 2025

moment(...) is local mode. Ambiguous input (without offset) is assumed to be local time. Unambiguous input (with offset) is adjusted to local time.
moment.utc(...) is utc mode. Ambiguous input is assumed to be UTC. Unambiguous input is adjusted to UTC.
[source for above]

This PR modifies bqutil.fn.cw_parse_timestamp to use moment.utc(...) to create timestamps assuming UTC to stay consistent with BQ.

eg:

SELECT
      parse_datetime('%Y%m%d %H%M%S', '20020211 123456') x,
      CAST(bqutil.fn.cw_parse_timestamp('20020211 123456789', 'YYYYMMDD HHmmssSSS') as DATETIME) z

outputs:

2002-02-11T12:34:56
2002-02-11T20:34:56.789000

They should be same with just difference in miliseconds.

@danieldeleo
Copy link
Collaborator

/gcbrun

@danieldeleo danieldeleo merged commit 1986a2d into GoogleCloudPlatform:master Sep 25, 2025
85 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments