Skip to content

Commit

Permalink
target converter from DateTime -> DateTimeOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmrdavid authored Nov 12, 2023
1 parent f7fb155 commit a014bb8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/Client/Core.Tests/Entities/EntityMetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public class EntityMetadataTests
readonly EntityInstanceId id = new("test", Random.Shared.Next(0, 100).ToString());

// create customize convert class
public class DateTimeConverter : JsonConverter<DateTime>
public class DateTimeConverter : JsonConverter<DateTimeOffset>
{
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return DateTime.Parse(reader.GetString());
return DateTimeOffset.Parse(reader.GetString());

Check warning on line 19 in test/Client/Core.Tests/Entities/EntityMetadataTests.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'input' in 'DateTimeOffset DateTimeOffset.Parse(string input)'.

Check warning on line 19 in test/Client/Core.Tests/Entities/EntityMetadataTests.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'input' in 'DateTimeOffset DateTimeOffset.Parse(string input)'.
}

public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToString("dd/MM/yyyy"));
}
Expand Down

0 comments on commit a014bb8

Please sign in to comment.