I've come up with the following code to generate a list of all dates between two given dates:
def generate_all_valid_dates_in_range(_start_date, _end_date) when _start_date <= _end_date do
(:calendar.date_to_gregorian_days(_start_date) .. :calendar.date_to_gregorian_days(_end_date))
|> Enum.to_list
|> Enum.map (&(:calendar.gregorian_days_to_date(&1)))
end
I would appreciate any comments on style and if there's some built in function (in either Elixir or Erlang) to achieve this sort of functionality.