We have added DateTime.from_iso8601 that can parse a ISO8601 as long as it
has an offset. It will convert the datetime to UTC (a valid timezone) and
also return the parsed offset.



*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Mon, Nov 28, 2016 at 10:39 PM, José Valim <
[email protected]> wrote:

> To think about it in another way, you lose the information when you do
>> `DateTime.to_iso8601`, not in `DateTime.from_iso8601`.  If anything,
>> it seems like `DateTime.to_iso8601` should be the controversial,
>> disclaimered transformation because this is the lossy point where
>> information about the specific locale is lost.
>>
>
>
> The issue is that DateTime.from_iso8601 does not contain enough
> information to build a DateTime in the first place. The time_zone field is
> not currently allowed to be nil (solution 1) and Etc/GMT+X does not support
> all offsets, such as 5.5h, which is a valid offset (solution 2).
>
> So I agree that DateTime.to_iso8601 is controversial (and we have warnings
> on its documentation) but at the moment DateTime.from_iso8601 is not
> possible. I believe it would only be possible if we convert it to UTC but I
> am not sure if it is a valid trade-off in our case.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Jp0dx5x%2BH6im3iho%2BXE2rB2Yg-%3Dh72nLTwHDgygH8ttA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to