Datix - A date-time parser using Calendar.strftime format strings

Hi,

datix is a date-time parse using Calendar.strftime format strings.
Some examples:

iex(1)> Datix.strptime("2021-01-13", "%x")
{:ok, %{day: 13, month: 1, year: 2021}}
iex(2)> Datix.strptime("21/01/10", "%y/%m/%d")
{:ok, %{day: 10, month: 1, year_2_digit: 21}}
iex(3)> Datix.strptime("1 PM", "%-I %p")
{:ok, %{am_pm: :pm, hour_12: 1}}
iex(4)> Datix.strptime("Di", "%a", abbreviated_day_of_week_names: ~w(Mo Di Mi Do Fr Sa So))
{:ok, %{day_of_week: 2}}
iex(5)> Datix.Date.parse("2021/04/15", "%Y/%m/%d")
{:ok, ~D[2021-04-15]}
iex(6)> Datix.NaiveDateTime.parse("2021/04/15 11:55:25", "%Y/%m/%d %X")
{:ok, ~N[2021-04-15 11:55:25]}
iex(7)> Datix.DateTime.parse("2018/12/30 11:23:55 CEST+0200", "%Y/%m/%d %H:%M:%S %Z%z")
{:ok, ~U[2018-12-30 09:23:55Z], {"CEST", 7200}}
iex(8)> Datix.Date.parse("1736/13/03", "%Y/%m/%d", calendar: Cldr.Calendar.Coptic)
{:ok, ~D[1736-13-03 Cldr.Calendar.Coptic]}

or more information, please see the documentation.

10 Likes