A string when not using an output range; void otherwise.
import mir.test; Timestamp.init.toString.should == "0000T"; Timestamp(2010, 7, 4).toString.should == "2010-07-04"; Timestamp(1998, 12, 25).toString.should == "1998-12-25"; Timestamp(0, 1, 5).toString.should == "0000-01-05"; Timestamp(-4, 1, 5).toString.should == "-0004-01-05"; // yyyy-mm-ddThh:mm:ss[.mmm]±hh:mm Timestamp(2021).toString.should == "2021T"; Timestamp(2021, 01).toString.should == "2021-01T"; Timestamp(2021, 01, 29).toString.should == "2021-01-29"; Timestamp(2021, 01, 29, 19, 42).withOffset(0).toString.should == "2021-01-29T19:42Z"; Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60).toString.should == "2021-01-29T19:42:44+07"; Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60 + 30).toString.should == "2021-01-29T20:12:44+07:30"; Timestamp.onlyTime(7, 40).toString.should == "07:40-00:00"; Timestamp.onlyTime(7, 40, 30).toString.should == "07:40:30-00:00"; Timestamp.onlyTime(7, 40, 30, -3, 56).withOffset(0).toString.should == "07:40:30.056Z";
// Test A.D. assert(Timestamp(9, 12, 4).toISOExtString == "0009-12-04"); assert(Timestamp(99, 12, 4).toISOExtString == "0099-12-04"); assert(Timestamp(999, 12, 4).toISOExtString == "0999-12-04"); assert(Timestamp(9999, 7, 4).toISOExtString == "9999-07-04"); assert(Timestamp(10000, 10, 20).toISOExtString == "+10000-10-20"); // Test B.C. assert(Timestamp(0, 12, 4).toISOExtString == "0000-12-04"); assert(Timestamp(-9, 12, 4).toISOExtString == "-0009-12-04"); assert(Timestamp(-99, 12, 4).toISOExtString == "-0099-12-04"); assert(Timestamp(-999, 12, 4).toISOExtString == "-0999-12-04"); assert(Timestamp(-9999, 7, 4).toISOExtString == "-9999-07-04"); assert(Timestamp(-10000, 10, 20).toISOExtString == "-10000-10-20"); assert(Timestamp.onlyTime(7, 40).toISOExtString == "07:40-00:00"); assert(Timestamp.onlyTime(7, 40, 30).toISOExtString == "07:40:30-00:00"); assert(Timestamp.onlyTime(7, 40, 30, -3, 56).toISOExtString == "07:40:30.056-00:00"); const cdate = Timestamp(1999, 7, 6); immutable idate = Timestamp(1999, 7, 6); assert(cdate.toISOExtString == "1999-07-06"); assert(idate.toISOExtString == "1999-07-06");
Converts this Timestamp to a string with the format yyyy-mm-ddThh:mm:ss[.mmm]±hh:mm.
If w writer is set, the resulting string will be written directly to it.