mirror of
https://github.com/Crunchy-DL/Crunchy-Downloader.git
synced 2026-01-11 20:10:26 +00:00
Add - Available dubs/subs overall to history series - not all dubs/subs are available for every season/episode Fix - Subscription end date was in UTC, causing the program to not recognize an active premium subscription https://github.com/Crunchy-DL/Crunchy-Downloader/issues/74
19 lines
No EOL
794 B
C#
19 lines
No EOL
794 B
C#
using System;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace CRD.Utils.JsonConv;
|
|
|
|
public class UtcToLocalTimeConverter : JsonConverter<DateTime>{
|
|
public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, JsonSerializer serializer){
|
|
return reader.Value switch{
|
|
null => DateTime.MinValue,
|
|
DateTime dateTime when dateTime.Kind == DateTimeKind.Utc => dateTime.ToLocalTime(),
|
|
DateTime dateTime => dateTime,
|
|
_ => throw new JsonSerializationException($"Unexpected token parsing date. Expected DateTime, got {reader.Value.GetType()}.")
|
|
};
|
|
}
|
|
|
|
public override void WriteJson(JsonWriter writer, DateTime value, JsonSerializer serializer){
|
|
writer.WriteValue(value);
|
|
}
|
|
} |