1
0
mirror of https://github.com/akpaevj/onecmonitor.git synced 2024-12-14 10:12:52 +02:00
onecmonitor/onecmonitor-server/Converters/Sqlite/DateTimeStringConverter.cs
2023-01-27 20:58:44 +03:00

12 lines
438 B
C#

using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace OnecMonitor.Server.Converters.Sqlite
{
public class DateTimeStringConverter : ValueConverter<DateTime, string>
{
public DateTimeStringConverter() : base(
g => g.Kind == DateTimeKind.Utc ? g.ToString() : g.ToUniversalTime().ToString(),
s => DateTime.SpecifyKind(DateTime.Parse(s), DateTimeKind.Utc)) { }
}
}