From ac769e656b122ff569c3f1534701b71e00fed586 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 27 Oct 2020 19:21:35 +0800 Subject: Split front and back end. --- Timeline/Models/Converters/MyDateTimeConverter.cs | 51 ----------------------- 1 file changed, 51 deletions(-) delete mode 100644 Timeline/Models/Converters/MyDateTimeConverter.cs (limited to 'Timeline/Models/Converters/MyDateTimeConverter.cs') diff --git a/Timeline/Models/Converters/MyDateTimeConverter.cs b/Timeline/Models/Converters/MyDateTimeConverter.cs deleted file mode 100644 index f125cd5c..00000000 --- a/Timeline/Models/Converters/MyDateTimeConverter.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.ComponentModel; -using System.Globalization; - -namespace Timeline.Models.Converters -{ - public class MyDateTimeConverter : TypeConverter - { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); - } - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - if (value is string text) - { - text = text.Trim(); - if (text.Length == 0) - { - return DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc); - } - - return DateTime.Parse(text, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); - } - - return base.ConvertFrom(context, culture, value); - } - - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if (destinationType == typeof(string) && value is DateTime) - { - DateTime dt = (DateTime)value; - if (dt == DateTime.MinValue) - { - return string.Empty; - } - - return dt.ToString("s", CultureInfo.InvariantCulture) + "Z"; - } - - return base.ConvertTo(context, culture, value, destinationType); - } - } -} -- cgit v1.2.3