Utf8jsonreader Datetimeoffset Parsing Rfc 3339 !free! File

throw new JsonException("Invalid RFC 3339 format");

ReadOnlySpan<byte> utf8Span = reader.ValueSpan; Span<char> buffer = stackalloc char[utf8Span.Length]; int chars = Encoding.UTF8.GetChars(utf8Span, buffer); ReadOnlySpan<char> dateStr = buffer.Slice(0, chars);

string dateString = reader.GetString();

If you need UTC normalization:

DateTimeOffset parsed = ParseDateTimeOffsetFromReader(ref reader); DateTimeOffset utc = parsed.ToUniversalTime(); | Error | Cause | |------------------------------------|-----------------------------------------------------------------------| | JsonException: Expected string | Token is not a string (maybe null or number). | | FormatException on TryParse | Missing T , wrong offset format ( +0530 instead of +05:30 ), wrong fractional seconds. | | Z not recognized | Some old parsers need ToUniversalTime() – not with DateTimeOffset . | utf8jsonreader datetimeoffset parsing rfc 3339

public class Event

throw new JsonException("Invalid RFC 3339 DateTimeOffset string."); throw new JsonException("Invalid RFC 3339 format")

if (reader.TokenType == JsonTokenType.String)