
Security News
Deno Goes the Way of the Dinosaur
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.
@google-cloud/precise-date
Advanced tools
A simple utility for precise-dateing functions and classes.
A simple utility for precise-dateing functions and classes.
It's unlikely you will need to install this package directly, as it will be
installed as a dependency when you install other @google-cloud packages.
$ npm install --save @google-cloud/precise-date
PreciseDate extends the native Date object, so you can use it in place of
that or when you need nanosecond precision.
const {PreciseDate} = require('@google-cloud/precise-date');
const date = new PreciseDate('1547253035381101032');
date.toISOString();
// => 2019-01-12T00:30:35.381101032Z
date.toFullTimeString();
// => '1547253035381101032'
Returns a new date instance.
Type: string BigInt Object<string, number> [number, number]
// from a full ISO string
date = new PreciseDate('2019-02-08T10:34:29.481145231Z');
// from a string representing nanoseconds
date = new PreciseDate('1549622069481320032');
// from a BigInt representing nanoseconds (requires Node >= 10.7)
date = new PreciseDate(1549622069481320032n);
// from an object containing `seconds` and `nanos` values
date = new PreciseDate({seconds: 1549622069, nanos: 481320032});
// from a tuple representing [seconds, nanos]
date = new PreciseDate([1549622069, 481320032]);
Similar to Date.parse(), but this accepts the same nanosecond time options as the PreciseDate constructor and returns a string representing the nanoseconds in the specified date according to universal time.
PreciseDate.parseFull('2019-02-08T10:34:29.481145231Z');
// => '1549622069481145231'
Similar to Date.UTC(), but also accepts microsecond and nanosecond parameters. Returns a string that represents the number of nanoseconds since January 1, 1970, 00:00:00 UTC.
Type: ...number
PreciseDate.fullUTCString(2019, 1, 8, 10, 34, 29, 481, 145, 231);
// => '1549622069481145231'
Like PreciseDate.fullUTCString() but returns a native BigInt instead of a string. Requires Node >= 10.7.
Type: ...number
PreciseDate.fullUTC(2019, 1, 8, 10, 34, 29, 481, 145, 231);
// => 1549622069481145231n
PreciseDate instance.
Returns a string of the specified date represented in nanoseconds according to universal time.
Like date.getFullTimeString() but returns a native BigInt instead of a string. Requires Node >= 10.7.
Returns the microseconds in the specified date according to universal time.
Returns the nanoseconds in the specified date according to universal time.
Sets the microseconds for a specified date according to universal time. Returns a string representing the nanoseconds in the specified date according to universal time.
Type: number
Sets the nanoseconds for a specified date according to universal time. Returns a string representing the nanoseconds in the specified date according to universal time.
Type: number
Sets the time to the number of supplied nanoseconds since January 1, 1970, 00:00:00 UTC. Returns a string representing the nanoseconds in the specified date according to universal time (effectively, the value of the argument).
Type: number string BigInt
Returns an object representing the specified date according to universal time.
Refer to google.protobuf.Timestamp for more information about this format.
const {seconds, nanos} = date.toStruct();
Like date.toStruct() but returns the seconds and nanos as a tuple.
const [seconds, nanos] = date.toTuple();
This library follows Semantic Versioning.
Contributions welcome! See the Contributing Guide.
Apache Version 2.0
See LICENSE
Moment.js is a popular date handling library that provides functions for parsing, validating, manipulating, and formatting dates. While it offers broad functionality for handling dates and times, it does not support nanosecond precision like @google-cloud/precise-date.
date-fns is a modular date utility library. Similar to Moment.js, it offers a variety of date manipulation and formatting options but lacks support for nanosecond precision, making @google-cloud/precise-date more suitable for applications requiring extremely precise time measurements.
FAQs
A simple utility for precise-dateing functions and classes.
The npm package @google-cloud/precise-date receives a total of 9,316,455 weekly downloads. As such, @google-cloud/precise-date popularity was classified as popular.
We found that @google-cloud/precise-date demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.

Security News
Anthropic’s free OSS Scanner uses Mythos and other Claude models to find open source vulnerabilities and send maintainers reports with proposed fixes.

Security News
On Front Lines’ Early Adopters: CISO podcast, Andrew Becherer shares lessons from Datadog, weighs the long-term costs of AI-built tools, and explains how founders can actually gain a CISO’s trust.