Skip to content

Adding Timestamp class #220

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

Merged
merged 9 commits into from
Jun 26, 2018
Merged

Adding Timestamp class #220

merged 9 commits into from
Jun 26, 2018

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Jun 25, 2018

This ports the new Timestamp class to Node JS.

Also:

  • Added GeoPoint range validation.
  • Fixed two docs issues.

A follow-up PR will use the new Timestamp type in the .createTime, .updateTime and .readTime.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 25, 2018
@codecov
Copy link

codecov bot commented Jun 25, 2018

Codecov Report

Merging #220 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #220   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     13    +1     
  Lines        1799   1834   +35     
=====================================
+ Hits         1799   1834   +35
Impacted Files Coverage Δ
src/timestamp.js 100% <100%> (ø)
src/document.js 100% <100%> (ø) ⬆️
src/index.js 100% <100%> (ø) ⬆️
src/validate.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e7619a...c5e5d18. Read the comment docs.

Copy link
Contributor

@var-const var-const left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the question about truncation. Otherwise LGTM with very small nits.

src/index.js Outdated
* `Timestamp` instead.
* <br/>NOTE: in the future `timestampsInSnapshots: true` will become the
* default and this option will be removed so you should change your code to
* use Timestamp now and opt-in to this new behavior as soon as you can.

This comment was marked as spam.

This comment was marked as spam.

'use strict';

const is = require('is');
const validate = require('./validate')();

This comment was marked as spam.

This comment was marked as spam.

*/
isEqual(other) {
return (
this === other ||

This comment was marked as spam.

This comment was marked as spam.

src/validate.js Outdated
return false;
}
if (value < min || value > max) {
throw new Error(`Value must be within [${min}, ${max}] inclusive.`);

This comment was marked as spam.

This comment was marked as spam.


assert.throws(() => {
new Firestore.GeoPoint();
}, expectedErr);
}, /Argument "latitude" is not a valid number/);

This comment was marked as spam.

This comment was marked as spam.

*
* NOTE: in the future `timestampsInSnapshots: true` will become the
* default and this option will be removed so you should change your code to
* use Timestamp now and opt-in to this new behavior as soon as you can.

This comment was marked as spam.

This comment was marked as spam.

.then(res => {
const timestamp = res.get('moonLanding');
assert.equal(timestamp.seconds, -14182920);
assert.equal(timestamp.nanoseconds, 123000123);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback addressed. Thanks for your review!

src/index.js Outdated
* `Timestamp` instead.
* <br/>NOTE: in the future `timestampsInSnapshots: true` will become the
* default and this option will be removed so you should change your code to
* use Timestamp now and opt-in to this new behavior as soon as you can.

This comment was marked as spam.

'use strict';

const is = require('is');
const validate = require('./validate')();

This comment was marked as spam.

*/
isEqual(other) {
return (
this === other ||

This comment was marked as spam.

src/validate.js Outdated
return false;
}
if (value < min || value > max) {
throw new Error(`Value must be within [${min}, ${max}] inclusive.`);

This comment was marked as spam.


assert.throws(() => {
new Firestore.GeoPoint();
}, expectedErr);
}, /Argument "latitude" is not a valid number/);

This comment was marked as spam.

.then(res => {
const timestamp = res.get('moonLanding');
assert.equal(timestamp.seconds, -14182920);
assert.equal(timestamp.nanoseconds, 123000123);

This comment was marked as spam.

*
* NOTE: in the future `timestampsInSnapshots: true` will become the
* default and this option will be removed so you should change your code to
* use Timestamp now and opt-in to this new behavior as soon as you can.

This comment was marked as spam.

@schmidt-sebastian
Copy link
Contributor Author

schmidt-sebastian commented Jun 26, 2018

Adding @stephenplusplus / @JustinBeckwith for approval. FYI: @var-const is a member of the client SDK team.

@schmidt-sebastian schmidt-sebastian merged commit 0ce0ed8 into master Jun 26, 2018
/**
* The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
*/
readonly seconds: number;

This comment was marked as spam.

This comment was marked as spam.

@Edalbrelord
Copy link

Edalbrelord commented Jul 20, 2018 via email

@hiranya911
Copy link

@Edalbrelord we can get a patch release out sometime next week.

@schmidt-sebastian schmidt-sebastian deleted the timestamps branch July 24, 2018 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants