mirror of
https://github.com/bitwarden/server.git
synced 2025-04-27 15:52:13 -05:00
17 lines
544 B
C#
17 lines
544 B
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Bit.Core.Utilities;
|
|
|
|
public class EpochDateTimeJsonConverter : JsonConverter<DateTime>
|
|
{
|
|
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
return CoreHelpers.FromEpocMilliseconds(reader.GetInt64());
|
|
}
|
|
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
|
{
|
|
writer.WriteNumberValue(CoreHelpers.ToEpocMilliseconds(value));
|
|
}
|
|
}
|