Skip to content

Commit 1986a2d

Browse files
authored
moment assumes PST instead of UTC. Change moment to create object assuming UTC to stay consistent with BQ. (#508)
1 parent 6bba14a commit 1986a2d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

udfs/community/cw_parse_timestamp.sqlx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CREATE OR REPLACE FUNCTION ${self()}(timeString STRING, formatString STRING)
2323
description="Emulates Oracle's TO_TIMESTAMP function.") AS
2424
"""
2525
// Return timeString with the given formatString in BigQuery canonical ISO format
26-
const momentObject = moment(timeString, formatString);
26+
const momentObject = moment.utc(timeString, formatString);
2727

2828
if(momentObject.isValid()) {
2929
return momentObject.toDate();

udfs/community/test_cases.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,11 +3070,11 @@ generate_udf_test("bignumber_lte", [
30703070
generate_udf_test("cw_parse_timestamp", [
30713071
{
30723072
inputs: [`"10-Sep-02 14:10:10.123000"`, `"DD-MMM-YY HH:mm:ss.SSSSSS"`,],
3073-
expected_output: `TIMESTAMP "2002-09-10 21:10:10.123000 UTC"`,
3073+
expected_output: `TIMESTAMP "2002-09-10 14:10:10.123000 UTC"`,
30743074
},
30753075
{
30763076
inputs: [`"10-Sep-02 14:10:10123000"`, `"DD-MMM-YY HH:mm:ssSSSSSS"`,],
3077-
expected_output: `TIMESTAMP "2002-09-10 21:10:10.123000 UTC"`,
3077+
expected_output: `TIMESTAMP "2002-09-10 14:10:10.123000 UTC"`,
30783078
},
30793079
{
30803080
inputs: [`"40-Sep-02 14:10:10123000"`, `"DD-MMM-YY HH:mm:ssSSSSSS"`,],

0 commit comments

Comments
 (0)