flutterfire
flutterfire copied to clipboard
Add `isUtc` to the `Timestamp.toDate`
Description
Ability to convert Timestamp objects to the UTC DateTime object.
In case, when we save UTC timestamps to the firestore, we need to restore them in that state.
Currently, we need to create DateTime someway like this:
final Timestamp timestamp = // get timestamp object
final datetime = DateTime.fromMicrosecondsSinceEpoch(
timestamp.microsecondsSinceEpoch,
isUtc: true,
);
With this changes we will just use build-in methods.
Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
- [x] All existing and new tests are passing.
- [x] I updated/added relevant documentation (doc comments with
///). - [x] The analyzer (
melos run analyze) does not report any problems on my PR. - [x] I read and followed the Flutter Style Guide.
- [x] I signed the CLA.
- [x] I am willing to follow-up on review comments in a timely manner.
Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
- [ ] Yes, this is a breaking change.
- [x] No, this is not a breaking change.
Hey @Vorkytaka, thanks for your PR. You can already convert easily using
timestamp.toDate().toUtc()
Do you think it's enough for your usecase? Thanks
Hey @Vorkytaka, thanks for your PR. You can already convert easily using
timestamp.toDate().toUtc()Do you think it's enough for your usecase? Thanks
The problem is that we create two DateTime objects. :(
Discussing internally we don't think the optimisation is worth adding the API.