Skip to content
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(firestore): add toJSON() and valueOf() to FirestoreTimestamp #4439

Merged
merged 2 commits into from
Nov 10, 2020

Conversation

pokey
Copy link
Contributor

@pokey pokey commented Oct 22, 2020

Description

For parity with JS SDK, and also to make comparisons work as expected. Copied from https://github.com/firebase/firebase-js-sdk/blob/7c1c7f182b59e0fc7d175f53e5e2360cdee0ccab/packages/firestore/src/api/timestamp.ts#L162-L182.

I just copied and pasted without testing or modification, so please lmk if this is something you'd be interested in including, and I'd be happy to add a unit test / clean / add type info to proper place

Related issues

Release Summary

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan


Think react-native-firebase is great? Please consider supporting the project with any of the below:

For parity with JS SDK, and also to make comparisons work as expected.  Copied from https://github.com/firebase/firebase-js-sdk/blob/7c1c7f182b59e0fc7d175f53e5e2360cdee0ccab/packages/firestore/src/api/timestamp.ts#L162-L182.

Please lmk if this is something you'd be interested in including, and I'd be happy to add a unit test
@CLAassistant
Copy link

CLAassistant commented Oct 22, 2020

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link

vercel bot commented Oct 22, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/invertase/react-native-firebase/a1v1mzwb1
✅ Preview: https://react-native-firebase-git-patch-1.invertase.vercel.app

@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #4439 (98a13b9) into master (513c345) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4439   +/-   ##
=======================================
  Coverage   41.92%   41.92%           
=======================================
  Files          35       35           
  Lines        1119     1119           
  Branches      278      278           
=======================================
  Hits          469      469           
  Misses        489      489           
  Partials      161      161           

@mikehardy mikehardy added the Workflow: Needs Review Pending feedback or review from a maintainer. label Oct 22, 2020
@mikehardy mikehardy changed the title Add toJSON() and valueOf() to FirestoreTimestamp feat(firestore): add toJSON() and valueOf() to FirestoreTimestamp Oct 23, 2020
@mikehardy mikehardy added Workflow: Pending Merge Waiting on CI or similar and removed Workflow: Needs Review Pending feedback or review from a maintainer. labels Nov 10, 2020
Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

@pokey 🏆 ! Sorry for the delay in reviewing this, there was one small lint error I corrected, but otherwise this looked great, I will merge this and do a release in an hour or so

@mikehardy mikehardy merged commit aca6992 into invertase:master Nov 10, 2020
@mikehardy mikehardy removed the Workflow: Pending Merge Waiting on CI or similar label Nov 10, 2020
@davidstott
Copy link

Should FirestoreTimestamp include MIN_SECONDS for valueOf to work?
Something like: const MIN_SECONDS = -62135596800;

@mikehardy
Copy link
Collaborator

@davidstott great catch! That's what we get for using javascript still instead of typescript 😞

The relevant lines we are missing are these https://github.com/firebase/firebase-js-sdk/blob/7c1c7f182b59e0fc7d175f53e5e2360cdee0ccab/packages/firestore/src/api/timestamp.ts#L21-L22

// The earlist date supported by Firestore timestamps (0001-01-01T00:00:00Z).
const MIN_SECONDS = -62135596800;

I'll PR it quickly

androidIsForVivek pushed a commit to androidIsForVivek/react-native-firebase that referenced this pull request Aug 9, 2021
…vertase#4439)

* Add toJSON() and valueOf() to FirestoreTimestamp

For parity with JS SDK, and also to make comparisons work as expected.  Copied from https://github.com/firebase/firebase-js-sdk/blob/7c1c7f182b59e0fc7d175f53e5e2360cdee0ccab/packages/firestore/src/api/timestamp.ts#L162-L182.

Please lmk if this is something you'd be interested in including, and I'd be happy to add a unit test

* Update packages/firestore/lib/FirestoreTimestamp.js

Co-authored-by: Mike Hardy <github@mikehardy.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants