-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Description
Hi all,
first I wanted to point out that Flutter is an amazing piece of software. I've seen quite some UI frameworks during my career, but this one basically blew my mind.
But, I encountered something strange. As far as I understand it, DateTime.millisecondsSinceEpoch must be timezone agnostic. That means, that
var tsu = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;
var tsl = DateTime.now().toLocal().millisecondsSinceEpoch ~/ 1000;
must report the same number (unless by some coincidence, the two calls fall into different 1000s bucket, but let's forget about that for a moment). So, millisecondsSinceEpoch is a universal number, regardless on which device and from which timezone it is called. That's what the definition says: "The number of milliseconds since 1970-01-01T00:00:00Z (UTC)"
And yes, both values are the same in my tests, like one would expect. But, the result of the above code differs between my Android emulator and a real device. The real device and the browser version show the correct value as seen on https://www.unixtimestamp.com/ while the emulator is one or two hours off. I guess the emulator queries the Windows API in the end and uses local time instead of UTC by accident.
Not a deal breaker for me (since the real device works correctly), but would be nice if it worked on the emulator, too.