Parsing a RFC1123z date string is not properly converting the input date to UTC
The example from the Parsing Dates section in the README doesn't work as expected. See the following steps to reproduce:
klausi@devil2:~/dev/timex (master)λ iex -S mix
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
Interactive Elixir (1.0.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> use Timex
nil
iex(2)> date = Date.from({{2013,3,5},{23,25,19}}, "Europe/Athens")
%Timex.DateTime{calendar: :gregorian, day: 5, hour: 23, minute: 25, month: 3,
ms: 0, second: 19,
timezone: %Timex.TimezoneInfo{abbreviation: "EET",
from: {:sunday, {{2012, 10, 28}, {3, 0, 0}}}, full_name: "Europe/Athens",
offset_std: 0, offset_utc: 120, until: {:sunday, {{2013, 3, 31}, {3, 0, 0}}}},
year: 2013}
iex(3)> {:ok, ^date} = DateFormat.parse("Tue, 05 Mar 2013 23:25:19 +0200", "{RFC1123z}")
** (MatchError) no match of right hand side value: {:ok, %Timex.DateTime{calendar: :gregorian, day: 5, hour: 23, minute: 25, month: 3, ms: 0, second: 19, timezone: %Timex.TimezoneInfo{abbreviation: "UTC", from: :min, full_name: "UTC", offset_std: 0, offset_utc: 0, until: :max}, year: 2013}}
There is an issue here, but the README also has a bug, as the parsing of that date will not be mapped to the Europe/Athens timezone (since all it contains is an offset, the target timezone should be Etc/GMT-2). I'm looking into why the offset is not resulting in the latter timezone being applied to the parsed date now. Thanks!
Correction, it looks like the bug here is that it's parsing the date as UTC because of the *z pattern, but it should be parsing it into the +0200 timezone then shifting to UTC. I think I know what broke this.
Ok found the problem and it's been fixed (and the README updated) in master. A new release was just pushed as well (0.14.2) containing the fix.
Great! Thank you very much :)