Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions changelog/interval_fromisostring.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Interval, PosInfInterval and NegInfInterval ISO 8601 string support

std.datetime.interval.Interval gained fromISOString, fromISOExtString,
toISOString and toISOExtString, with PosInfInterval and NegInfInterval
gaining the same for their open-ended forms. The strings hold two time
points or a time point and a duration separated by a slash, e.g.
$(D "20030115/P1M"), where per ISO 8601 an omitted side means that it is
unknown: Interval then extends to the smallest or largest time point which
the time point type can represent, whereas PosInfInterval and
NegInfInterval represent true infinity, e.g. $(D "20030115/") and
$(D "/20030215").

As with the date and time types in std.datetime, each value in a duration
must be within the range which its unit can hold (e.g. hours are at most
23), so a larger span must be expressed with the next larger designator,
e.g. $(D P1DT12H) rather than $(D PT36H).

Example:
-------
import std.datetime.date;
import std.datetime.interval;

auto i = Interval!Date.fromISOString("20030115/P1M");
assert(i == Interval!Date(Date(2003, 1, 15), Date(2003, 2, 15)));

// Round trip: parse, write, parse again, and compare.
assert(Interval!Date.fromISOString(i.toISOString()) == i);

// An omitted side means that the interval extends as far as the time
// point type can represent.
assert(Interval!Date.fromISOString("20030115/") ==
Interval!Date(Date(2003, 1, 15), Date.max));
assert(PosInfInterval!Date(Date(2003, 1, 15)).toISOString() == "20030115/");
-------
Loading
Loading