Skip to content

Commit

Permalink
Support parsing object to DateTimeOffset and preserve timezone offset (
Browse files Browse the repository at this point in the history
…#16732)

(cherry picked from commit 4643b7d)
  • Loading branch information
ronaldbarendse authored and bergmania committed Jul 4, 2024
1 parent 0a9df3c commit 33338ad
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOp
JsonTokenType.Number when reader.TryGetInt32(out int i) => i,
JsonTokenType.Number when reader.TryGetInt64(out long l) => l,
JsonTokenType.Number => reader.GetDouble(),
JsonTokenType.String when reader.TryGetDateTimeOffset(out DateTimeOffset datetime) => datetime,
JsonTokenType.String when reader.TryGetDateTime(out DateTime datetime) => datetime,
JsonTokenType.String => reader.GetString()!,
JsonTokenType.String => reader.GetString(),
_ => JsonDocument.ParseValue(ref reader).RootElement.Clone()
};
}
Expand Down

0 comments on commit 33338ad

Please sign in to comment.