mathieuprog / tz

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

Wrong zone_abbr in some time zones #1

Closed NickNeck closed 4 years ago

NickNeck commented 4 years ago

Hello,

I have found some wrong zone_abbr:

iex(1)> Tz.TimeZoneDatabase.time_zone_periods_from_wall_datetime(~N[1905-09-15 05:36:31], "Europe/London")
{:ok,
 %{
   from: %{
     utc_gregorian_seconds: 58314556875,
     wall_gregorian_seconds: 58314556875
   },
   std_offset: 0,
   to: %{
     utc_gregorian_seconds: 60475255200,
     wall_gregorian_seconds: 60475255200
   },
   utc_offset: 0,
   zone_abbr: ""
 }}
iex(2)> Tz.TimeZoneDatabase.time_zone_periods_from_wall_datetime(~N[1923-05-22 11:54:39], "Asia/Tokyo")
{:ok,
 %{
   from: %{
     utc_gregorian_seconds: 59579506800,
     wall_gregorian_seconds: 59579539200
   },
   std_offset: 0,
   to: %{
     utc_gregorian_seconds: 61483417200,
     wall_gregorian_seconds: 61483449600
   },
   utc_offset: 32400,
   zone_abbr: "JT"
 }}
iex(3)> Tz.TimeZoneDatabase.time_zone_periods_from_wall_datetime(~N[1948-06-05 21:50:01], "America/Nassau")
{:ok,
 %{
   from: %{
     utc_gregorian_seconds: 60342124170,
     wall_gregorian_seconds: 60342106170
   },
   std_offset: 0,
   to: %{
     utc_gregorian_seconds: 61987878000,
     wall_gregorian_seconds: 61987860000
   },
   utc_offset: -18000,
   zone_abbr: "ET"
 }}

The expected zone_abbr are:

input: ~N[1905-09-15 05:36:31], "Europe/London"
expected zone_abbr: "GMT"

input: ~N[1923-05-22 11:54:39], "Asia/Tokyo"
expected zone_abbr: "JST"

input: ~N[1948-06-05 21:50:01], "America/Nassau"
expected zone_abbr: "EST"

I assume this happens for zone-state that refers to a rule without a transition (no rule is applied) in the zone-state.

mathieuprog commented 4 years ago

Fixed ✌️ Thank you for reporting!

mathieuprog commented 4 years ago

Re-opened as the fix was not enough.

Tz.TimeZoneDatabase.time_zone_periods_from_wall_datetime(
  ~N[1991-03-31 20:00:00], "Asia/Dushanbe")

zone_abbr is "+05/+06". Should be either +05 for standard offset or +06 for dst offset.

mathieuprog commented 4 years ago

Fixed