Convert parsed EDTF structs into a {start_date, end_date} tuple of
Date.t() values suitable for SQL- or Ecto-style range queries.
The user-facing entry point is EDTF.to_date_range/1, which accepts an EDTF
string and delegates here once parsing has succeeded. This module can also be
called directly with an already-parsed struct.
Semantics
- Bounded inputs yield two concrete
Date.t()values. - Explicitly open inputs (
/..,../,[..2020],[2020..]) yield:unboundedon the open side. - Inputs with an unknown bound (
1985/,/1985) yield:unknownon that side. - Qualifiers (
~,?,%) are ignored — the range uses the nominal date. - Unspecified digits (
X) are expanded to their full place-value span when they form a contiguous suffix of a component (e.g.19XX→ 1900-01-01 to 1999-12-31). Non-suffix unspecified digits return{:error, :unsupported}. - Seasons map to month ranges (quarters, quadrimesters, semesters are unambiguous; codes 21–24 are treated as northern-hemisphere; Winter and southern-hemisphere Summer span the year boundary).
Summary
Functions
Convert a parsed EDTF struct (or a parse/1 result tuple) into a
{start_date, end_date} tuple.