tz icon indicating copy to clipboard operation
tz copied to clipboard

fix: DateTime.add/3 `:nanosecond` precision error

Open ceolinrenato opened this issue 6 months ago • 1 comments

Steps to reproduce:

DateTime.add(DateTime.utc_now(), 1_000, :nanosecond, Tz.TimeZoneDatabase)

(added a test that reproduces it)

ceolinrenato avatar Jun 27 '25 16:06 ceolinrenato

@mathieuprog https://github.com/mathieuprog/tz/pull/34/commits/7f2fbb3fc428ac89551b9c361f8b419ae5f5f930 generalizes the conversion, but it looks like elixir uses microsecond precision by default and there's no higher precision than nanoseconds. So I'm not sure which solution is better, as not using constants for this could lead into weird behaviours

we can revert https://github.com/mathieuprog/tz/pull/34/commits/7f2fbb3fc428ac89551b9c361f8b419ae5f5f930 if you agree

ceolinrenato avatar Jun 27 '25 17:06 ceolinrenato