Class JsonUniversalDateTimeConverter
Converts a DateTime value to or from JSON, always converting the value to Coordinated Universal Time (UTC) when reading.
Inheritance
System.Object
System.Text.Json.Serialization.JsonConverter
System.Text.Json.Serialization.JsonConverter <DateTime >
ReadOnlyJsonConverter <DateTime >
Namespace: Umbraco.Cms.Infrastructure.Serialization
Assembly: Umbraco.Infrastructure.dll
Syntax
public sealed class JsonUniversalDateTimeConverter : ReadOnlyJsonConverter<DateTime>
Remarks
In order to match the existing behaviour, and that of MessagePack, we need to ensure that DateTimes are always read as UTC. This is not the case by default for System.Text.Json, see: https://github.com/dotnet/runtime/issues/1566.
Methods
View SourceRead(ref Utf8JsonReader, Type, JsonSerializerOptions)
Declaration
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
Type | Name | Description |
---|---|---|
System. |
reader | |
Type | typeToConvert | |
System. |
options |
Returns
Type | Description |
---|---|
Date |