Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timex.Timezone.local/0 fails with :could_not_resolve_timezone in the hour after DST starts #755

Open
dyxyl opened this issue Apr 3, 2024 · 0 comments

Comments

@dyxyl
Copy link

dyxyl commented Apr 3, 2024

Steps to reproduce

Call Timex.Timezone.local/0 when the system time is within 1 hour after DST starts (the missing hour of local time). For example, at ~U[2024-03-31 01:13:41.097331Z] when TZ=Europe/London.

Description of issue

I would expect Timex.Timezone.local/0 to return the DST timezone like it does in the hour that follows the failing case.

Instead, it returns a :could_not_resolve_timezone error.

Timex.Timezone.local/0 calls Timex.Timezone.local/1 with the current UTC. The documentation for Timex.Timezone.local/1 doesn't say if the argument is in UTC or local time.

Here is an example session with timex 3.7.11 and TZ=Europe/London. (2) and (3) show it working before DST starts. (4), (5) and (6) show it failing during the changeover. (7) and (8) show it working again after the changeover.

iex(1)> Application.ensure_all_started(:timex)
{:ok,
 [:crypto, :asn1, :public_key, :ssl, :unicode_util_compat, :idna, :mimerl,
  :certifi, :syntax_tools, :parse_trans, :ssl_verify_fun, :metrics, :hackney,
  :tzdata, :combine, :expo, :gettext, :timex]}
iex(2)> Timex.Timezone.local
#<TimezoneInfo(Europe/London - GMT (+00:00:00))>
iex(3)> Timex.now
~U[2024-03-31 00:58:30.182979Z]
iex(4)> Timex.now
~U[2024-03-31 01:13:41.097331Z]
iex(5)> Timex.Timezone.local
{:error, {:could_not_resolve_timezone, "Europe/London", 63879066824, :wall}}
iex(6)> Timex.now
~U[2024-03-31 01:13:54.824859Z]
iex(7)> Timex.now
~U[2024-03-31 02:01:56.322685Z]
iex(8)> Timex.Timezone.local
#<TimezoneInfo(Europe/London - BST (+01:00:00))>
iex(9)> Application.started_applications
[
  {:timex,
   ~c"Timex is a rich, comprehensive Date/Time library for Elixir projects, with full timezone support via the :tzdata package.\nIf you need to manipulate dates, times, datetimes, timestamps, etc., then Timex is for you!\n",
   ~c"3.7.11"},
  {:gettext, ~c"Internationalization and localization through gettext",
   ~c"0.23.1"},
  {:expo,
   ~c"Low-level Gettext file handling (.po/.pot/.mo file writer and parser).",
   ~c"0.4.1"},
  {:combine, ~c"A parser combinator library for Elixir projects.", ~c"0.10.0"},
  {:tzdata, ~c"Tzdata is a parser and library for the tz database.\n",
   ~c"1.1.1"},
  {:hackney, ~c"simple HTTP client", ~c"1.20.1"},
  {:metrics, ~c"A generic interface to different metrics systems in Erlang.",
   ~c"1.0.1"},
  {:ssl_verify_fun, ~c"SSL verification library", ~c"1.1.7"},
  {:parse_trans, ~c"Parse transform library", ~c"3.4.1"},
  {:syntax_tools, ~c"Syntax tools", ~c"3.0.1"},
  {:certifi, ~c"CA bundle adapted from Mozilla by https://certifi.io",
   ~c"2.12.0"},
  {:mimerl, ~c"Library to handle mimetypes", ~c"1.2.0"},
  {:idna, ~c"A pure Erlang IDNA implementation", ~c"6.1.1"},
  {:unicode_util_compat, ~c"unicode_util compatibility library for Erlang < 20",
   ~c"0.7.0"},
  {:ssl, ~c"Erlang/OTP SSL application", ~c"10.9.1.3"},
  {:public_key, ~c"Public key infrastructure", ~c"1.13.3.2"},
  {:asn1, ~c"The Erlang ASN1 compiler version 5.0.21.1", ~c"5.0.21.1"},
  {:crypto, ~c"CRYPTO", ~c"5.1.4.2"},
  {:logger, ~c"logger", ~c"1.15.7"},
  {:iex, ~c"iex", ~c"1.15.7"},
  {:elixir, ~c"elixir", ~c"1.15.7"},
  {:compiler, ~c"ERTS  CXC 138 10", ~c"8.2.6.4"},
  {:stdlib, ~c"ERTS  CXC 138 10", ~c"4.3.1.3"},
  {:kernel, ~c"ERTS  CXC 138 10", ~c"8.5.4.2"}
]
iex(10)> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant