The OpenD Programming Language

Timestamp

Timestamp

Note: The component values in the binary encoding are always in UTC or local time with unknown offset, while components in the text encoding are in a some timezone with known offset. This means that transcoding requires a conversion between UTC and a timezone.

Timestamp precision is up to picosecond (second/10^12).

@serdeRegister
struct Timestamp {}

Constructors

this
this(const(char)[] str)
this
this(short year)
this
this(short year, ubyte month)
this
this(short year, ubyte month, ubyte day)
this
this(short year, ubyte month, ubyte day, ubyte hour, ubyte minute)
this
this(short year, ubyte month, ubyte day, ubyte hour, ubyte minute, ubyte second)
this
this(short year, ubyte month, ubyte day, ubyte hour, ubyte minute, ubyte second, byte fractionExponent, ulong fractionCoefficient)
this
this(Date datetime)
this
this(TimeOfDay timeOfDay)
this
this(DateTime datetime)
this
this(SysTime systime)
this
this(Duration duration)

Creates a fake timestamp from a Duration using total!"hnsecs" method. For positive and zero timestamps the format is wwww-dd-88Thh:mm:ss.nnnnnnn and for negative timestamps wwww-dd-99Thh:mm:ss.nnnnnnn.

Members

Aliases

fromISOExtString
alias fromISOExtString = fromISOStringImpl!true

Creates a Timestamp from a string with the format yyyy-mm-ddThh:mm:ss[.mmm]±hh:mm or its leading part allowed by the standard.

fromISOString
alias fromISOString = fromISOStringImpl!false

Creates a Timestamp from a string with the format `YYYYMMDDThhmmss±hhmm or its leading part allowed by the standard.

fromYamlString
alias fromYamlString = fromISOStringImpl!(true, true)

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

toISOExtString
alias toISOExtString = toISOStringImp!true

Converts this Timestamp to a string with the format yyyy-mm-ddThh:mm:ss[.mmm]±hh:mm.

toISOString
alias toISOString = toISOStringImp!false

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

toString
alias toString = toISOExtString

Converts this Timestamp to a string with the format yyyy-mm-ddThh:mm:ss[.mmm]±hh:mm.

Enums

Precision
enum Precision

Functions

addMinutes
void addMinutes(short minutes)

Helpfer for time zone offsets

getFraction
long getFraction()
isDuration
bool isDuration()
isLocalTime
bool isLocalTime()
isNegativeDuration
bool isNegativeDuration()
isOnlyTime
bool isOnlyTime()
offset
short offset()

Timezone offset in minutes

offset
void offset(ushort offset)
opCast
T opCast()

Decomposes Timestamp to an algebraic type. Supported types up to T.stringof equivalence:

opCast
T opCast()

Casts timestamp to a date-time type.

opCmp
int opCmp(Timestamp rhs)
setLocalTimezone
void setLocalTimezone()
toUnixTime
long toUnixTime()
withOffset
Timestamp withOffset(short minutes)

Attaches local offset, doesn't adjust other fields. Local-time offsets may be represented as either hour*60+minute offsets from UTC, or as the zero to denote a local time of UTC. They are required on timestamps with time and are not allowed on date values.

Static functions

fromString
bool fromString(const(C)[] str, Timestamp value)
Timestamp fromString(const(C)[] str)

Creates a Timestamp from a string.

fromUnixTime
Timestamp fromUnixTime(long time)
onlyTime
Timestamp onlyTime(ubyte hour, ubyte minute)
onlyTime
Timestamp onlyTime(ubyte hour, ubyte minute, ubyte second)
onlyTime
Timestamp onlyTime(ubyte hour, ubyte minute, ubyte second, byte fractionExponent, ulong fractionCoefficient)

Templates

toISOStringImp
template toISOStringImp(bool ext)
Undocumented in source.

Variables

day
ubyte day;

Day

fractionCoefficient
ulong fractionCoefficient;

Fraction

fractionExponent
byte fractionExponent;

Fraction

hour
ubyte hour;

Hour

minute
ubyte minute;

Minute

month
ubyte month;

Month

precision
Precision precision;
second
ubyte second;

Second

year
short year;

Year

Meta