srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
102 stars 54 forks source link

TZDateTime drops microseconds #27

Closed jsmarr closed 5 years ago

jsmarr commented 5 years ago

TZDateTime takes microseconds as an optional constructor param (for parity with DateTime), but internally it calls _utcFromLocalDateTime, which only uses the milliseconds for conversion, effectively dropping the microseconds in the process.

Basic repro case: final tzDateTime = TZDateTime(getLocation('America/Los_Angeles'), 2019, DateTime.april, 8, 15, 16, 23, 62, 500); expect(tzDateTime.microsecond, 500); // Fails (returns 0).

Fix would be to use microseconds for _utcFromLocalDateTime or at least re-add the microseconds at the end of the conversion (they shouldn't impact the underlying logic).