Is there an existing issue for this?
Which plugins are affected?
Cloud Firestore
Which platforms are affected?
Android, iOS, macOS, Web, Windows
Description
Creating a Timestamp (from package cloud_firestore_platform_interface) with the factories fromMicrosecondsSinceEpoch and fromMillisecondsSinceEpoch, passing a negative value with non-zero millisecond value (which could come from a DateTime object representing a date before 1970-01-01, causes _validateRange to throw because it fails the precondition _check(nanoseconds >= 0, 'nanoseconds', nanoseconds);.
The thrown exception is
Invalid argument(s): Timestamp nanoseconds out of range: -<nanoseconds>
This is due to erroneous calculation of nanoseconds in the body of the aforementioned factories.
Reproducing the issue
final date = DateTime(1969, 06, 22, 0, 0, 0, 123);
final timestamp = Timestamp.fromDate(date); // this throws
Firebase Core version
3.12.1
Flutter Version
3.29.1
Relevant Log Output
Flutter dependencies
No response
Additional context and comments
No response
Is there an existing issue for this?
Which plugins are affected?
Cloud Firestore
Which platforms are affected?
Android, iOS, macOS, Web, Windows
Description
Creating a
Timestamp(from packagecloud_firestore_platform_interface) with the factoriesfromMicrosecondsSinceEpochandfromMillisecondsSinceEpoch, passing a negative value with non-zero millisecond value (which could come from aDateTimeobject representing a date before 1970-01-01, causes_validateRangeto throw because it fails the precondition_check(nanoseconds >= 0, 'nanoseconds', nanoseconds);.The thrown exception is
Invalid argument(s): Timestamp nanoseconds out of range: -<nanoseconds>This is due to erroneous calculation of nanoseconds in the body of the aforementioned factories.
Reproducing the issue
Firebase Core version
3.12.1
Flutter Version
3.29.1
Relevant Log Output
Flutter dependencies
No response
Additional context and comments
No response