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 
depending on 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 <ebart...@gmail.com> 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 elixir-lang-co...@googlegroups.com.
>>
> 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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/ddc6ebbb-fa50-43a1-881b-e93ddcf426fdn%40googlegroups.com.

Reply via email to