-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(timestamp): create new date/timestamp classes #517
Conversation
Codecov Report
@@ Coverage Diff @@
## master #517 +/- ##
==========================================
+ Coverage 89.87% 89.95% +0.07%
==========================================
Files 15 15
Lines 1432 1443 +11
Branches 42 42
==========================================
+ Hits 1287 1298 +11
Misses 140 140
Partials 5 5
Continue to review full report at Codecov.
|
@JustinBeckwith I'm not sure what your feelings are on my Timestamp class, but assuming it is something we would like to move forward with, I think it would be better suited for |
I'm +1 to exposing nanosecond precision in a reusable way across our libs. Is common really the right place for it though? Thinking out loud:
Adding @ofrobots and @googleapis/node-team as they will know if there's already something in the ecosystem we should be using, or if what you got here is of enough value to the community to spin out :) |
Oh also @callmehiphop silly question - is this a breaking change? |
Yeah, technically it is, I hadn't released our latest major breaking change yet so my plan was to ship this with it. |
How does this compare to something like nano-date? |
My preference would be a new public module for this. This seems like a feature anybody could take advantage of. IMHO there is no reason to sequester it into the
|
@stephenplusplus I made some changes to the |
Fixes #494
Fixes #526
Closes #529
Timestamps
This PR brings a new class for dealing with Cloud Spanner Timestamps. Previously we would return Date objects, but these were only good for millisecond precision. Since timestamps can come from the API in the form of either an ISO string or a protobuf timestamp, the class can handle either allowing users to easily use commit and read timestamps in queries, as well as result timestamps in snapshot bounds.
With ISO string.
With protobuf timestamp.
The Timestamp class extends the native Date class, so users can perform basic operations to the Timestamp if they choose.
It will also accept any single value that the Date object would accept in scenarios where micro-precision isn't important.
SpannerDate
To keep dealing with date times consistent, I've also refactored the SpannerDate class to extend the native Date class. It accepts any single value that the Date class would also accept.