notsure
Timex.to_datetime() does not return %Timex.AmbiguousDateTime{}
Hello all and thanks in advance!
I am writing tests to handle time changes from DST and back. I cannot seem to trigger the %Timex.Ambiguous{} response from Timex.to_datetime():
iex(10)> Timex.to_datetime({{2023, 11, 5},{01, 30, 00}}, "US/Mountain")
#DateTime<2023-11-05 01:30:00-06:00 MDT US/Mountain>
I originally was setup on {:timex, "~> 3.6.1"}, where I was able to trigger the correct response, but then I upgraded to {:timex, "~> 3.7.11"}. I don’t know if that change caused the response to change as I was not looking for it (was still learning how Timex works). But now that I know what I am looking for I have done a mix.deps clean --all and rebuilt to {:timex, "~> 3.6.1"}. I still do not get the expected result.
Any ideas what I am doing wrong?
Marked As Solved
LostKobrakai
I’d suggest sticking to core APIs wherever possible:
iex(1)> DateTime.new(~D[2023-11-05], ~T[01:30:00], "US/Mountain")
{:ambiguous, #DateTime<2023-11-05 01:30:00-06:00 MDT US/Mountain>,
#DateTime<2023-11-05 01:30:00-07:00 MST US/Mountain>}
Edit: This requires a timezone database (like tzdata) to be installed and configured for usage.








