Table of Contents

Struct DateTimeOffsetConverter

Namespace
DynaSharp.Serialization
Assembly
DynaSharp.dll

Converts DateTimeOffset to and from a string value (S) holding the instant in UTC in the round-trip form 2026-10-31T12:00:00.0000000Z: always seven fraction digits, always Z.

public readonly struct DateTimeOffsetConverter : IDynamoDbConverter<DateTimeOffset>
Implements
Inherited Members

Remarks

The offset is not preserved: 12:00+02:00 is stored as 10:00Z and read back with offset zero. That is what makes stored values comparable as text, so a key condition or a BETWEEN over the attribute orders chronologically. Keep the offset in an attribute of its own if it matters.

Reading also accepts the ISO 8601 forms other writers produce: fewer fraction digits (2026-10-31T12:00:00.123Z, as the AWS SDK for .NET writes) and an offset instead of Z; the instant is converted to UTC. Text without Z or an offset is rejected, since it would name a local time without saying whose.

Explicit Interface Implementations

Read(ref DynamoDbReader, AttributeType)

Reads the attribute value the reader is positioned on.

static DateTimeOffset Read(ref DynamoDbReader reader, AttributeType type)

Parameters

reader DynamoDbReader

The reader, positioned on the value after ReadStartAttribute() or TryReadStartAttribute(out AttributeType). The caller reads the closing brace afterwards, so the converter must read the value completely (all elements of a list, map or set) and nothing more.

type AttributeType

The DynamoDB type of the value. Check it with Expect(AttributeType, AttributeType), which throws JsonException for types the converter does not support. Null is passed to the converter too, so it can map it to null where that makes sense.

Returns

DateTimeOffset

The value.

Exceptions

JsonException

type is not String.

FormatException

The text is not an ISO 8601 date and time with Z or an offset. The message does not quote the text.

Write(DynamoDbWriter, DateTimeOffset)

Writes a value as one complete attribute value, for example with WriteNumber<T>(T).

static void Write(DynamoDbWriter writer, DateTimeOffset value)

Parameters

writer DynamoDbWriter

The writer, positioned where a value is expected (after an attribute name, or inside a list). It is a ref struct, so it is never null and needs no check.

value DateTimeOffset

The value.