Struct TimeSpanConverter
- Namespace
- DynaSharp.Serialization
- Assembly
- DynaSharp.dll
Converts TimeSpan to and from a string value (S) in the constant format [-][d.]hh:mm:ss[.fffffff], for example
1.02:03:04.5000000.
public readonly struct TimeSpanConverter : IDynamoDbConverter<TimeSpan>
- Implements
- Inherited Members
Remarks
The text does not order like the value (a negative span, or one of 10 days against one of 2), so do not use it for sorting or range conditions.
Explicit Interface Implementations
Read(ref DynamoDbReader, AttributeType)
Reads the attribute value the reader is positioned on.
static TimeSpan Read(ref DynamoDbReader reader, AttributeType type)
Parameters
readerDynamoDbReaderThe 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.
typeAttributeTypeThe 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
- TimeSpan
The value.
Exceptions
- JsonException
typeis not String.- FormatException
The text is not a time span in the constant format. The message does not quote the text.
Write(DynamoDbWriter, TimeSpan)
Writes a value as one complete attribute value, for example with WriteNumber<T>(T).
static void Write(DynamoDbWriter writer, TimeSpan value)
Parameters
writerDynamoDbWriterThe 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.
valueTimeSpanThe value.