[Proposal] DateTime.from_iso8601!/2

48 views
Skip to first unread message

Anthony Smith

unread,
Aug 29, 2017, 11:19:22 AM8/29/17
to elixir-lang-core
Parses the extended “DateTimes” format described by ISO 8601:2004.

Raises if the format is invalid.

This function would be similar to Date.from_iso8601!/2.

José Valim

unread,
Aug 29, 2017, 11:59:52 AM8/29/17
to elixir-l...@googlegroups.com
ISO does not specify the timezone, so we cannot parse it into a DateTime. You can use NaiveDateTime or, if you want to assume a timezone, parse a NaiveDateTime and then convert it to DateTime.



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
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 elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/821de85c-7b35-4bf3-88f8-ddcc24d3cc32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony Smith

unread,
Aug 29, 2017, 12:06:17 PM8/29/17
to elixir-lang-core, jose....@plataformatec.com.br
DateTime already has from_iso8601/2. I thought it might make sense to have a version that returns a DateTime instead of a tuple. Similar to Date.from_iso8601!/2.

I'm not sure what parsing has to do with it considering there's already a function that parses ISO 8601 into DateTime. I apologize if I'm missing something obvious.

On Tuesday, August 29, 2017 at 11:59:52 AM UTC-4, José Valim wrote:
ISO does not specify the timezone, so we cannot parse it into a DateTime. You can use NaiveDateTime or, if you want to assume a timezone, parse a NaiveDateTime and then convert it to DateTime.



José Valim
Skype: jv.ptec
Founder and Director of R&D

On Tue, Aug 29, 2017 at 5:19 PM, Anthony Smith <ant...@sticksnleaves.com> wrote:
Parses the extended “DateTimes” format described by ISO 8601:2004.

Raises if the format is invalid.

This function would be similar to Date.from_iso8601!/2.

--
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 elixir-lang-co...@googlegroups.com.

José Valim

unread,
Aug 29, 2017, 12:53:48 PM8/29/17
to elixir-l...@googlegroups.com
Oh, apologies. I misunderstood the proposal. You want to add a bang variant. Definitely. Please send a PR.
--
Reply all
Reply to author
Forward
0 new messages