Cadena de elixir a DateTime
defmodule SomeModule do
@doc """
iex> SomeModule.to_date("2020-01-30")
~D[2020-01-30]
"""
def to_date(string), do: Date.from_iso8601!(string)
@doc """
iex> SomeModule.to_date_time("1997-07-16T19:20:30.45Z")
~U[1997-07-16 19:20:30.45Z]
"""
def to_date_time(string) do
case DateTime.from_iso8601(string) do
{:ok, date_time, _offset} -> date_time
error -> error
end
end
end
Uncommon Nightingale