I have an issue where I want to run a date string through a parser function.
Since my database holds data from third parties, the date strings come in many different formats so I have to run the string through several functions to return a proper datetime.
I'm trying to find an elegant way to do something like this (psuedocode):
my_date = cond {:ok, date} do
Timex.parse(datestr, "{RFC1123}") -> date
Timex.parse(datestr, "{RFC1123z}") -> date
Timex.parse(datestr, "{RFC822}") -> date
Timex.parse(datestr, "{RFC822z}") -> date
...more formats
end
do_something_with_date(my_date)
This sounds trivial but I'm pretty stumped honestly