The OpenD Programming Language

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.

import mir.timestamp;
struct Timestamp
@serdeIgnore
alias toISOString = toISOStringImp!false

Return Value

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

Examples

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

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

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

Meta