The OpenD Programming Language

IonTimestamp

Ion Timestamp

Timestamp representations have 7 components, where 5 of these components are optional depending on the precision of the timestamp. The 2 non-optional components are offset and year. The 5 optional components are (from least precise to most precise): month, day, hour and minute, second, fraction_exponent and fraction_coefficient. All of these 7 components are in Universal Coordinated Time (UTC).

Members

Functions

get
Timestamp get()

Describes decimal.

get
IonErrorCode get(T value)

Describes decimal (nothrow version).

getErrorCode
IonErrorCode getErrorCode()
serialize
void serialize(S serializer)

Variables

data
const(ubyte)[] data;

Examples

import mir.timestamp;

// null.timestamp
assert(IonValue([0x6F]).describe.get!IonNull == IonNull(IonTypeCode.timestamp));

ubyte[][] set = [
    [0x68, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84,         ], // 2000-07-08T02:03:04Z with no fractional seconds
    [0x69, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84, 0x80,   ], // The same instant with 0d0 fractional seconds and implicit zero coefficient
    [0x6A, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84, 0x80, 00], // The same instant with 0d0 fractional seconds and explicit zero coefficient
    [0x69, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84, 0xC0,   ], // The same instant with 0d-0 fractional seconds
    [0x69, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84, 0x81,   ], // The same instant with 0d1 fractional seconds
];

auto r = Timestamp(2000, 7, 8, 2, 3, 4).withOffset(0);

foreach(data; set)
{
    assert(IonValue(data).describe.get!IonTimestamp.get == r);
}

assert(IonValue([0x69, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84, 0xC2])
    .describe
    .get!IonTimestamp
    .get ==
        Timestamp(2000, 7, 8, 2, 3, 4, -2, 0).withOffset(0));

assert(IonValue([0x6A, 0x80, 0x0F, 0xD0, 0x87, 0x88, 0x82, 0x83, 0x84, 0xC3, 0x10])
    .describe
    .get!IonTimestamp
    .get ==
        Timestamp(2000, 7, 8, 2, 3, 4, -3, 16).withOffset(0));

Meta