mathieuprog / tz

Time zone support for Elixir
Apache License 2.0
125 stars 11 forks source link

Time converting and back is not symmetrical #24

Closed adkron closed 3 months ago

adkron commented 7 months ago

I have some property tests that I wrote for a project where we are using tz. I ran into a specific date time that has an issue. Here is a test for it.


  # in config
  config :elixir, :time_zone_database, Tz.TimeZoneDatabase

  # TEST

  test "bad property" do
    date_time_utc = ~U[2029-12-31 10:15:00Z]
    time_zone = "Pacific/Chatham"

    zoned_date_time =
      date_time_utc
      |> DateTime.shift_zone!(time_zone)

    naive = DateTime.to_naive(zoned_date_time)

    assert zoned_date_time == DateTime.from_naive!(naive, time_zone)
  end

It fails until ~U[2030-01-01 00:00:00Z] is the input at which point it passes.

Any year before 2029 passes. Any year after 2029 fails.

I tried to determine why and ran out of time. I'm happy to help figure this out. I don't really know where to start.

mathieuprog commented 7 months ago

This has been fixed in version 0.26.4 :)

adkron commented 7 months ago

Maybe we should get together on this. I was able to fail another now. ~U[2016-03-27 02:00:00Z], "America/Asuncion". Are you okay with a propcheck test? I can make one. That is how I'm finding these.

Some others

~U[2009-11-01 09:00:00Z], "America/Anchorage"
~U[2013-10-27 00:00:00Z], "Africa/Ceuta"
~U[2010-10-30 15:00:00Z], "Asia/Khandyga"