You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
@@ -881,6 +882,10 @@ export class BigQuery extends Service {
881
882
* A timestamp represents an absolute point in time, independent of any time
882
883
* zone or convention such as Daylight Savings Time.
883
884
*
885
+
* The recommended input here is a `Date` or `PreciseDate` class.
886
+
* If passing as a `string`, it should be Timestamp literals: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#timestamp_literals.
887
+
* When passing a `number` input, it should be epoch seconds in float representation.
888
+
*
884
889
* @method BigQuery.timestamp
885
890
* @param {Date|string} value The time.
886
891
*
@@ -890,12 +895,19 @@ export class BigQuery extends Service {
* A timestamp represents an absolute point in time, independent of any time
896
904
* zone or convention such as Daylight Savings Time.
897
905
*
898
-
* @param {Date|string} value The time.
906
+
* The recommended input here is a `Date` or `PreciseDate` class.
907
+
* If passing as a `string`, it should be Timestamp literals: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#timestamp_literals.
908
+
* When passing a `number` input, it should be epoch seconds in float representation.
909
+
*
910
+
* @param {Date|string|string|number} value The time.
899
911
*
900
912
* @example
901
913
* ```
@@ -904,10 +916,6 @@ export class BigQuery extends Service {
* The recommended input here is a `Date` or `PreciseDate` class.
2217
+
* If passing as a `string`, it should be Timestamp literals: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#timestamp_literals.
2218
+
* When passing a `number` input, it should be epoch seconds in float representation.
2219
+
*
2207
2220
*/
2208
2221
exportclassBigQueryTimestamp{
2209
2222
value: string;
@@ -2217,13 +2230,15 @@ export class BigQueryTimestamp {
2217
2230
if(/^\d{4}-\d{1,2}-\d{1,2}/.test(value)){
2218
2231
pd=newPreciseDate(value);
2219
2232
}else{
2220
-
pd=newPreciseDate(BigInt(value)*BigInt(1000));
2233
+
constfloatValue=Number.parseFloat(value);
2234
+
if(!Number.isNaN(floatValue)){
2235
+
pd=this.fromFloatValue_(floatValue);
2236
+
}else{
2237
+
pd=newPreciseDate(value);
2238
+
}
2221
2239
}
2222
-
}elseif(value){
2223
-
pd=newPreciseDate(BigInt(value)*BigInt(1000));
2224
2240
}else{
2225
-
// Nan or 0 - invalid dates
2226
-
pd=newPreciseDate(value);
2241
+
pd=this.fromFloatValue_(value);
2227
2242
}
2228
2243
// to keep backward compatibility, only converts with microsecond
2229
2244
// precision if needed.
@@ -2233,6 +2248,15 @@ export class BigQueryTimestamp {
2233
2248
this.value=newDate(pd.getTime()).toJSON();
2234
2249
}
2235
2250
}
2251
+
2252
+
fromFloatValue_(value: number): PreciseDate{
2253
+
constsecs=Math.trunc(value);
2254
+
// Timestamps in BigQuery have microsecond precision, so we must
0 commit comments