diff options
Diffstat (limited to 'Timeline/Models/Converters/MyDateTimeConverter.cs')
-rw-r--r-- | Timeline/Models/Converters/MyDateTimeConverter.cs | 51 |
1 files changed, 0 insertions, 51 deletions
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);
- }
- }
-}
|