JediHelpers.DateUtils (jedi_helpers v0.2.3)
Summary
Functions
Parses a variety of date formats into a Date
struct.
Supported inputs
""
or"0"
– returnsnil
- A
Date
struct – returns the date itself - Excel serial date string (e.g.
"40135"
) – returns the correspondingDate
- ISO-ish strings (e.g.
"2023-1-5"
,"2023-01-05"
) – returns the parsedDate
- Strings with leading/trailing whitespace are trimmed
- Invalid or malformed strings return
nil
Examples
iex> to_date("40135") ~D[2009-11-18]
iex> to_date("2024-1-9") ~D[2024-01-09]
iex> to_date("") nil
iex> to_date(%Date{year: 2020, month: 5, day: 10}) ~D[2020-05-10]
iex> to_date("not a date") nil