Last active
February 6, 2021 09:46
-
-
Save osaxma/6a323d7813d735b362d246337f73ca02 to your computer and use it in GitHub Desktop.
lost microseconds with DateTime.parse or DateTime.fromMicrosecondsSinceEpoch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on Flutter 1.26.0-17.3.pre Dart SDK 2.10.4 | |
// filed issue at https://github.com/dart-lang/sdk/issues/44876 | |
main() { | |
final datetimeParsed = DateTime.parse('2021-02-05T22:37:12.933232+00:00'); | |
final datetimeMS = DateTime.fromMicrosecondsSinceEpoch(1612564632933232); | |
print(datetimeParsed.toIso8601String()); // prints 2021-02-05T22:37:12.933Z | |
print(datetimeMS.toUtc().toIso8601String()); // prints 2021-02-05T22:37:12.933Z | |
print(datetimeParsed.microsecondsSinceEpoch); // prints 1612564632933000 | |
print(datetimeMS.microsecondsSinceEpoch); // prints 1612564632933000 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment