as you can see one is a date and the other is a datetime.
what’s the best way to go about this?
maybe convert them into something else?
and then transform them back when i want to return them?
As others said, it is likely a bad idea, but assuming you have to handle such input for reasons beyond your control, you can always trying parsing as one and then fallback to the other. I am not sure which order is best but here is an example:
case Date.from_iso8601(maybe_datetime) do
{:ok, date} -> convert_date_to_datetime(...)
{:error, _} ->
case NaiveDateTime.from_iso(maybe_datetime) do
{:ok, naive} -> convert_naive_to_datetime(...)
{:error, _} -> ...
end
end