Timestamp.toISOString

Converts this Timestamp to a string with the format YYYYMMDDThhmmss±hhmm.

If w writer is set, the resulting string will be written directly to it.

struct Timestamp
@serdeIgnore
alias toISOString = toISOStringImp!false

Return Value

A string when not using an output range; void otherwise.

Examples

assert(Timestamp.init.toISOString == "0000T");
assert(Timestamp(2010, 7, 4).toISOString == "20100704");
assert(Timestamp(1998, 12, 25).toISOString == "19981225");
assert(Timestamp(0, 1, 5).toISOString == "00000105");
assert(Timestamp(-4, 1, 5).toISOString == "-00040105");

// YYYYMMDDThhmmss±hhmm
assert(Timestamp(2021).toISOString == "2021T");
assert(Timestamp(2021, 01).toISOString == "2021-01T"); // always extended
assert(Timestamp(2021, 01, 29).toISOString == "20210129");
assert(Timestamp(2021, 01, 29, 19, 42).toISOString == "20210129T1942Z");
assert(Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60).toISOString == "20210129T194244+07");
assert(Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60 + 30).toISOString == "20210129T201244+0730");
static assert(Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60 + 30).toISOString == "20210129T201244+0730");

assert(Timestamp.onlyTime(7, 40).toISOString == "T0740Z");
assert(Timestamp.onlyTime(7, 40, 30).toISOString == "T074030Z");
assert(Timestamp.onlyTime(7, 40, 30, -3, 56).toISOString == "T074030.056Z");

Meta