There is some related discussion on this in this thread 
<https://groups.google.com/g/elixir-lang-core/c/CcXpeMQhsmU/m/uIgj-K7eDwAJ>. 
Some relevant take-aways are that even in the context of the most common 
standard formatting, it is hard™️ to get correct and not trivial to 
optimize (see: the great amount of effort 
<https://github.com/elixir-lang/elixir/pulls?q=iso> put into to getting 
what we have today right). I'm not sure that's how we want the core team to 
be spending their time compared to other language features, so I definitely 
prefer keeping the maintenance burden slim here and outsourcing more 
robust, configurable, quicker-to-iterate parsers in libraries.

On Tuesday, September 13, 2022 at 8:37:21 AM UTC-4 Bartolomeo wrote:

> I think using libraries for such tasks would make deps dir too heavy and 
> with reusing of Calendar strftime options Elixir codebase shouldn’t grow 
> much. Currently I use regexes to check allowed dates of birth formats from 
> different clients, eventually we can parse them to dt, I noticed many 
> countries still haven't adopted ISO 8601 
> https://en.wikipedia.org/wiki/Date_format_by_country, so I just have a 
> feeling it would be consistent and elegant if it would be it in Calendar 
> especially if strftime produces formatted output. For instance %b format 
> from strftime options could be reused to match exact range of abbreviated 
> months from input and I think it should be pretty sufficient for parsing.
>
> wtorek, 13 września 2022 o 13:52:44 UTC+2 José Valim napisał(a):
>
>> There are also libraries for this purpose, such as 
>> https://hex.pm/packages/datix and 
>> https://hex.pm/packages/date_time_parser.
>>
>> On Tue, Sep 13, 2022 at 1:45 PM Bartolomeo <[email protected]> wrote:
>>
>>> I noticed most of countries still haven't adopted ISO 8601 
>>> https://en.wikipedia.org/wiki/Date_format_by_country
>>
>>
>>> wtorek, 13 września 2022 o 13:26:19 UTC+2 Bartolomeo napisał(a):
>>>
>>>> I'd love to have in standard library ability to parse date strings with 
>>>> custom formatters defined by accepted formats 
>>>> <https://hexdocs.pm/elixir/1.12/Calendar.html#strftime/3-accepted-formats> 
>>>> Calendar 
>>>> has in place.
>>>>
>>>> I found few libraries that allows me to do this like:
>>>>
>>>> https://elixirforum.com/t/datix-a-date-time-parser-using-calendar-strftime-format-strings/36824
>>>> or
>>>> https://elixirforum.com/t/date-formats-phoenix-and-ecto/5220/19
>>>>
>>>> To avoid multiple regexes or dependencies to fulfill different client 
>>>> needs it could support formats provided in second arg of ie. 
>>>> `Date.parse_date("21/05/1985", "%d/%m/%Y")`, it would be opposite of 
>>>> `Calendar.strftime` so it would parse a given string, to the date, time or 
>>>> datetime.
>>>>
>>> -- 
>>>
>> 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/8d93b269-5059-43dd-adea-26eb6b08563cn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/elixir-lang-core/8d93b269-5059-43dd-adea-26eb6b08563cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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/69f99c8c-5073-44ae-a5d2-3cb6e19eecd6n%40googlegroups.com.

Reply via email to