Skip to content

Instantly share code, notes, and snippets.

@Roms1383
Last active September 10, 2022 16:35
Show Gist options
  • Save Roms1383/31bcd2c74cb3e23dc4dd33176bfa224f to your computer and use it in GitHub Desktop.
Save Roms1383/31bcd2c74cb3e23dc4dd33176bfa224f to your computer and use it in GitHub Desktop.
lossy conversion ?
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})');
}
@Roms1383
Copy link
Author

Tested on stable: Flutter 3.3.1 Dart 2.18.0.

@Roms1383
Copy link
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