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

Timezone MDT not supported for parsing (yet it works for formatting) #686

Open
AdamLeMmon01 opened this issue Sep 13, 2021 · 4 comments
Open

Comments

@AdamLeMmon01
Copy link

AdamLeMmon01 commented Sep 13, 2021

Steps to reproduce

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
@tfantina
Copy link

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".

Elixir 1.13
Timex 3.7.6

@halostatue
Copy link

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
Copy link

darwin67 commented Jul 12, 2023

Seems like it started happening from this commit, which is included in 3.7.3 release
91cd0ed

@bitwalker
Just want to clarify, the example in the docs will fail since the TZ database change.

iex(7)> Timex.parse("Tue Mar 5 23:25:19 PST 2013", "{UNIX}")
{:error, :time_zone_not_found}

https://hexdocs.pm/timex/Timex.Format.DateTime.Formatters.Default.html

Is this expected?

I see 3.7.3 changelog mention potential breaking changes for incorrect behavior, and is Tue Mar 5 23:25:19 PST 2013 considered incorrect?
https://github.com/bitwalker/timex/blob/main/CHANGELOG.md#373

@noozo
Copy link

noozo commented Jul 13, 2023

Got the same this morning with "PST". Same result with {:error, :time_zone_not_found} when using Timex.Timezone.convert.

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

5 participants