You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The microseconds of DateTime are lost when working with ToFirestore<R> for a withConverter for a CollectionReference being implicitly converted to Timestamp.
Steps to reproduce
Steps to reproduce the behavior:
Tap the floating action button
Observe terminal output with expected result and actual result
Repeat as desired with different DateTime inputs
Expected behavior
DateTime should be converted without the loss of microseconds.
Sample project
This bug requires a Firebase project to reproduce. As such, the code needed to reproduce the problem is being provided in place of a repository URL. Anyone who would like to reproduce the bug is encouraged to create a new Firebase project in order to compile the following code sample. The code sample provided makes use of the Firestore emulator.
Note
The following code sample uses a custom object with ToFirestore and FromFirestore. There is a more concise version of the code sample, in a separate comment below, that reproduces the bug and does not involve a custom object.
This bug occurs while using either the emulator or a live Firebase project.
This bug does not occur when converting DateTime to a Timestamp beforehand: Timestamp.fromDate(customDateTime.dateTime). This can be seen by modifying the above example:
[√] Flutter (Channel stable, 3.16.5, [redacted])
[√] [redacted]
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - [redacted] (Visual Studio Community 2022 17.0.5)
[√] Android Studio (version 2023.1)
[√] IntelliJ IDEA Community Edition (version 2023.3)
[√] VS Code (version 1.85.1)
[√] Connected device ([redacted])
[√] Network resources
• No issues found!
Flutter dependencies
Run flutter pub deps -- --style=compact and paste the output below:
Bug report
Describe the bug
The microseconds of
DateTimeare lost whenworking withbeing implicitly converted to Timestamp.ToFirestore<R>for awithConverterfor aCollectionReferenceSteps to reproduce
Steps to reproduce the behavior:
Expected behavior
DateTime should be converted without the loss of microseconds.
Sample project
This bug requires a Firebase project to reproduce. As such, the code needed to reproduce the problem is being provided in place of a repository URL. Anyone who would like to reproduce the bug is encouraged to create a new Firebase project in order to compile the following code sample. The code sample provided makes use of the Firestore emulator.
Note
The following code sample uses a custom object with
ToFirestoreandFromFirestore. There is a more concise version of the code sample, in a separate comment below, that reproduces the bug and does not involve a custom object.Additional context
This bug occurs while using either the emulator or a live Firebase project.
This bug does not occur when converting
DateTimeto aTimestampbeforehand:Timestamp.fromDate(customDateTime.dateTime). This can be seen by modifying the above example:Example Inputs / Outputs
Expected DateTime: 2023-11-01 00:00:00.000001
. . .Actual DateTime: 2023-11-01 00:00:00.000
Expected DateTime: 2023-11-01 00:00:00.001001
. . .Actual DateTime: 2023-11-01 00:00:00.001
Expected DateTime: 2023-11-01 00:00:00.999999
. . .Actual DateTime: 2023-11-01 00:00:00.999
Expected DateTime: 2023-11-01 23:59:59.999999
. . .Actual DateTime: 2023-11-01 23:59:59.999
Expected DateTime: 2023-11-30 23:59:59.999999
. . .Actual DateTime: 2023-11-30 23:59:59.999
Flutter doctor
Run
flutter doctorand paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compactand paste the output below:Click To Expand