googleapis / googleapis/google-cloud-node
Cannot instantiate PreciseDate with JS primitive number `0` or `BigInt(0)`
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 712
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 99
Description
When trying to instantiate the PreciseDate class with the zero epoch time, it fails.
#### Environment details
- OS: macOS
- Node.js version: 18.12.1
- npm version: 9.4.0
- `@google-cloud/precise-date` version: 4.0.0
#### Steps to reproduce
1. Try to instantiate a PreciseDate with BigInt(0) or 0
2. Throws `Error: TypeError: Cannot convert a BigInt value to a number at PreciseDate`
The issue is that this line https://github.com/googleapis/nodejs-precise-date/blob/04b3784b0a9948687cbd98a2be376246589c372c/src/index.ts#L122 , needs to explicitly check for zero values, as zero is a valid PreciseDate.
I'll try to submit a PR later, but in the meantime a hotfix will be applyed on the BigQuery library for this issue by calling `PreciseDate.parseFull` + `preciseDateInstance.setFulltime`
Reference issue: https://github.com/googleapis/nodejs-bigquery/issues/1353
Contributor guide
Assessment
This issue has not been assessed yet.