Table of Contents

Class XapiTimestamp

Namespace
Xapi
Assembly
Xapi.Core.dll

Reads and writes xAPI timestamps (timestamp, stored).

public static class XapiTimestamp
Inheritance
XapiTimestamp
Inherited Members

Remarks

Reading accepts RFC 3339 date-times: YYYY-MM-DDTHH:MM:SS[.fraction](Z|±HH:MM), with t and z also allowed in lower case. xAPI 2.0 also allows a space instead of T. A UTC offset is required and -00:00 ("unknown local offset", RFC 3339 4.3) is rejected, as the conformance suite expects. Results are converted to UTC (IEEE 9274.1.1, 4.2.7 "Timestamps").

Writing always uses UTC with a Z suffix and a fixed number of fraction digits: three, or seven when the value has sub-millisecond ticks. Trimming trailing zeros makes some LRS conformance checks flaky (ADL CTS issue #281), so they are never trimmed.

Methods

Format(DateTimeOffset)

Formats a timestamp in UTC as yyyy-MM-ddTHH:mm:ss.fffZ, or with seven fraction digits when the value has sub-millisecond ticks.

public static string Format(DateTimeOffset value)

Parameters

value DateTimeOffset

The instant.

Returns

string

The RFC 3339 text.

Parse(string, XapiVersion)

Parses a timestamp and converts it to UTC.

public static DateTimeOffset Parse(string value, XapiVersion version)

Parameters

value string

The timestamp text.

version XapiVersion

The xAPI version whose rules apply.

Returns

DateTimeOffset

The instant, with a zero offset.

Exceptions

FormatException

The text is not a valid timestamp for version.

TryParse(string?, XapiVersion, out DateTimeOffset)

Tries to parse a timestamp and convert it to UTC.

public static bool TryParse(string? value, XapiVersion version, out DateTimeOffset timestamp)

Parameters

value string

The timestamp text.

version XapiVersion

The xAPI version whose rules apply.

timestamp DateTimeOffset

The instant, with a zero offset, when the method returns true.

Returns

bool

true when the text is a valid timestamp.