The OpenD Programming Language

Timestamp.fromYamlString

Creates a Timestamp from a YAML string format or its leading part allowed by the standard.

import mir.timestamp;
struct Timestamp
@serdeIgnore
alias fromYamlString = fromISOStringImpl!(true, 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

// canonical
assert(Timestamp.fromYamlString("2001-12-15T02:59:43.1Z") == Timestamp("2001-12-15T02:59:43.1Z"));
// with lower 't' separator
assert(Timestamp.fromYamlString("2001-12-14t21:59:43.1-05:30") == Timestamp("2001-12-14T21:59:43.1-05:30"));
// yaml space separated
assert(Timestamp.fromYamlString("2001-12-14 21:59:43.1 -5") == Timestamp("2001-12-14T21:59:43.1-05"));
// no time zone (Z)
assert(Timestamp.fromYamlString("2001-12-15 2:59:43.10") == Timestamp("2001-12-15T02:59:43.10"));
// date 00:00:00Z
assert(Timestamp.fromYamlString("2002-12-14") == Timestamp("2002-12-14"));

Meta