diff --git a/lib/types.js b/lib/types.js index 63726fc3..7e96c26a 100644 --- a/lib/types.js +++ b/lib/types.js @@ -361,7 +361,7 @@ function toPrimitive_TIMESTAMP_MILLIS(value) { } function fromPrimitive_TIMESTAMP_MILLIS(value) { - return new Date(+value); + return new Date(parseInt(value)); } function toPrimitive_TIMESTAMP_MICROS(value) { @@ -382,7 +382,13 @@ function toPrimitive_TIMESTAMP_MICROS(value) { } function fromPrimitive_TIMESTAMP_MICROS(value) { - return new Date(parseInt(value / 1000n)); + if (value === undefined) { + return new Date(Nan); + } else if (typeof value === 'bigint') { + return new Date(parseInt(value / 1000n)); + } else { + return new Date(value / 1000); + } } function toPrimitive_INTERVAL(value) {