Dowser.Type.DateRange (Dowser.Client v0.5.0)

View Source

date_range — the %{"gte" => _, "lte" => _} object form <-> a Date.Range.

Only a field formatted strict_date is cast, since that is the one whose bounds are dates and nothing more — what a Date.Range holds. Its bounds are read with Date.from_iso8601/1.

Anything else is returned as it is stored: a field with another format (or none, which the backend reads as strict_date_optional_time||epoch_millis), exclusive gt/lt bounds, a bound that isn't a date, and on the way out a Date.Range whose step isn't 1.

iex> Dowser.Type.DateRange.load(
...>   %{"gte" => "2026-08-01", "lte" => "2026-08-11"},
...>   %{"type" => "date_range", "format" => "strict_date"}
...> )
Date.range(~D[2026-08-01], ~D[2026-08-11])

iex> Dowser.Type.DateRange.load(
...>   %{"gte" => "2026-08-01T00:00:00Z", "lte" => "2026-08-11T00:00:00Z"},
...>   %{"type" => "date_range"}
...> )
%{"gte" => "2026-08-01T00:00:00Z", "lte" => "2026-08-11T00:00:00Z"}