Timestamp.fromISOExtString

Creates a Timestamp from a string with the format YYYY-MM-DDThh:mm:ss±hh:mm or its leading part allowed by the standard.

struct Timestamp
@serdeIgnore
alias fromISOExtString = fromISOStringImpl!true

Return Value

bool on success for two arguments overload, and the resulting timestamp for single argument overdload.

Throws

DateTimeException if the given string is not in the correct format. Two arguments overload is nothrow.

Examples

assert(Timestamp.fromISOExtString("2010-07-04") == Timestamp(2010, 7, 4));
assert(Timestamp.fromISOExtString("1998-12-25") == Timestamp(1998, 12, 25));
assert(Timestamp.fromISOExtString("0000-01-05") == Timestamp(0, 1, 5));
assert(Timestamp.fromISOExtString("-0004-01-05") == Timestamp(-4, 1, 5));

assert(Timestamp(2021) == Timestamp.fromISOExtString("2021"));
assert(Timestamp(2021) == Timestamp.fromISOExtString("2021T"));
assert(Timestamp(2021, 01) == Timestamp.fromISOExtString("2021-01"));
assert(Timestamp(2021, 01) == Timestamp.fromISOExtString("2021-01T"));
assert(Timestamp(2021, 01, 29) == Timestamp.fromISOExtString("2021-01-29"));
assert(Timestamp(2021, 01, 29, 19, 42) == Timestamp.fromISOExtString("2021-01-29T19:42"));
assert(Timestamp(2021, 01, 29, 19, 42) == Timestamp.fromISOExtString("2021-01-29T19:42Z"));
assert(Timestamp(2021, 01, 29, 19, 42, 12) == Timestamp.fromISOExtString("2021-01-29T19:42:12"));
assert(Timestamp(2021, 01, 29, 19, 42, 12, -3, 67) == Timestamp.fromISOExtString("2021-01-29T19:42:12.067Z"));
assert(Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60) == Timestamp.fromISOExtString("2021-01-29T19:42:44+07"));
assert(Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60 + 30) == Timestamp.fromISOExtString("2021-01-29T20:12:44+07:30"));
static assert(Timestamp(2021, 01, 29, 12, 42, 44).withOffset(7 * 60 + 30) == Timestamp.fromISOExtString("2021-01-29T20:12:44+07:30"));
static assert(Timestamp(2021, 01, 29,  4, 42, 44).withOffset(- (7 * 60 + 30)) == Timestamp.fromISOExtString("2021-01-28T21:12:44-07:30"));

Meta