Created with <3 with dartpad.dev.
Last active
September 10, 2022 16:35
-
-
Save Roms1383/31bcd2c74cb3e23dc4dd33176bfa224f to your computer and use it in GitHub Desktop.
lossy conversion ?
This file contains hidden or 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
| void main() { | |
| final past_ms = -150151152153154; | |
| final future_ms = 150151152153154; | |
| final past = DateTime.fromMicrosecondsSinceEpoch(past_ms, isUtc: true); | |
| print('$past (ms ${past.microsecondsSinceEpoch})'); | |
| final future = DateTime.fromMicrosecondsSinceEpoch(future_ms, isUtc: true); | |
| print('$future (ms ${future.microsecondsSinceEpoch})'); | |
| } |
Author
Author
On the other side, the equivalent in Rust:
1965-03-30 03:20:48.846846 UTC (ms -150151151153154)
1974-10-04 20:39:12.153154 UTC (ms 150151152153154)Check Rust playground gist.
Author
Well actually it gets weirder when comparing with different int sizes, see this another gist.
Author
Tested on stable: Flutter 3.3.1 Dart 2.18.0.
Author
update: conversion isn't lossy on platform other than web and DartPad.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output in dart console:
so reverse conversion in Rust is lossy ?
notice how the last part of the digit e.g.
154in150151152153154or150_151_152_153_154is missing fromDateTime microsecondsSinceEpoch.