DateRange
The days from start to end, both included, written 2026-10-01/2026-10-31.
Time and calendar; not ordered; since Jadpo 0.1.0.
Make one
Build one from its fields, DateRange { start: ... end: ... }.
text.parse(raw, as: DateRange) reads one from its text; text that isn't one at all fails malformed, such as 2026-10-31/2026-10-01, 2026-10-01 or 2026-10-01/...
This operation gives one: range.intersection.
Its parts keep these rules; a value that breaks one fails with the rule's name:
start_not_after_end:start <= end
Fields
| Field | Type |
|---|---|
start |
CalendarDate |
end |
CalendarDate |
Text, JSON and storage
text.from writes its canonical text, the one form text.parse reads back. JSON sends an object of its parts.
| Text | JSON |
|---|---|
2026-10-01/2026-10-31 |
{"start":"2026-10-01","end":"2026-10-31"} |
2026-10-25/2026-10-25 |
{"start":"2026-10-25","end":"2026-10-25"} |
It is stored in one column named for the field, of type daterange. 2026-10-25/2026-10-25 is stored as daterange('2026-10-25'::date, '2026-10-25'::date, '[]').
Shown to people
text.format(value, locale:) shows it to people in their locale. A call also gives format:.
With locale: Locale.en_gb and format: TimeFormat.date_medium:
| Value | Shown |
|---|---|
2026-10-01/2026-10-31 |
1 Oct 2026 – 31 Oct 2026 |
2026-10-25/2026-10-25 |
25 Oct 2026 – 25 Oct 2026 |
Operations
range.contains(range: Range<T>, value: T) -> Bool: Whethervalueis insiderange.range.intersection(a: Range<T>, b: Range<T>) -> Range<T>?: The partaandbshare;nonewhen they don't overlap.range.overlaps(a: Range<T>, b: Range<T>) -> Bool: Whetheraandbshare at least one value.
Like every standard type, it also has the contract's own operations: text.parse, text.from, text.format, json.read, json.write and ==. It isn't ordered, so < and sorting don't take it. Every standard type meets one contract says how they work.
Markdown for agents: /docs/types/type-date-range.md.Built from Jadpo main at e00e61f.