You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Timezone MDT not supported for parsing (yet it works for formatting) #686
format_str = "{YYYY}-{M}-{D} {h24}:{m}:{s} {Zabbr}"
{:ok, datetime} = DateTime.new(~D[2021-09-13], ~T[00:00:00.000], "America/Denver")
{:ok, d } = Timex.format(datetime, format_str) # this outputs MDT as the timezone, but it cannot parse the datetime back from that string.
IO.puts d # => "2021-9-13 00:00:00 MDT"
IO.inspect Timex.parse(d, format_str) # => {:error, :time_zone_not_found}
Description of issue
Using the same input string, the formatted output should be able to be re-parsed to a date time.
Clearly the library recognizes MDT as a valid date time because I do not have MDT anywhere in my code. It is correctly converting from America/Denver to MDT, but it cannot parse it back from MDT again.
In the above example, the output of d should match the input of datetime. I believe the format call will return MDT part of the year and MST part of the year, but the end result or parsing it again should still return the same DateTime
I just encountered something similar when updating an app. Timex.now("MDT") seemed to work in an iex session but in tests it would output {:error, :time_zone_not_found}, fixed it by using "America/Denver".
This also affects Timex.parse(d, "…%Z…", :strftime) and appears to be a change that happened since 3.7.0. I can’t find the code that would have changed this in the history, so I’m wondering if it has to do with tzdata 1.0?
Activity
tfantina commentedon Dec 22, 2021
I just encountered something similar when updating an app.
Timex.now("MDT")seemed to work in aniexsession but in tests it would output{:error, :time_zone_not_found}, fixed it by using"America/Denver".Elixir 1.13
Timex 3.7.6
halostatue commentedon Apr 20, 2023
This also affects
Timex.parse(d, "…%Z…", :strftime)and appears to be a change that happened since 3.7.0. I can’t find the code that would have changed this in the history, so I’m wondering if it has to do with tzdata 1.0?darwin67 commentedon Jul 12, 2023
Seems like it started happening from this commit, which is included in
3.7.3release91cd0ed
@bitwalker
Just want to clarify, the example in the docs will fail since the TZ database change.
https://hexdocs.pm/timex/Timex.Format.DateTime.Formatters.Default.html
Is this expected?
I see
3.7.3changelog mention potential breaking changes for incorrect behavior, and isTue Mar 5 23:25:19 PST 2013considered incorrect?https://github.com/bitwalker/timex/blob/main/CHANGELOG.md#373
noozo commentedon Jul 13, 2023
Got the same this morning with "PST". Same result with
{:error, :time_zone_not_found}when usingTimex.Timezone.convert.