Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ConvertTo() [1/2]

override? object System.ComponentModel.DateTimeOffsetConverter.ConvertTo ( ITypeDescriptorContext? context,
CultureInfo? culture,
object? value,
Type destinationType )
inlinevirtual

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 56 of file DateTimeOffsetConverter.cs.

57 {
58 if (destinationType == typeof(string) && value is DateTimeOffset dateTimeOffset)
59 {
60 if (dateTimeOffset == DateTimeOffset.MinValue)
61 {
62 return string.Empty;
63 }
64 if (culture == null)
65 {
67 }
68 DateTimeFormatInfo dateTimeFormatInfo = null;
69 dateTimeFormatInfo = (DateTimeFormatInfo)culture.GetFormat(typeof(DateTimeFormatInfo));
71 {
72 if (dateTimeOffset.TimeOfDay.TotalSeconds == 0.0)
73 {
74 return dateTimeOffset.ToString("yyyy-MM-dd zzz", culture);
75 }
76 return dateTimeOffset.ToString(culture);
77 }
78 string text = ((dateTimeOffset.TimeOfDay.TotalSeconds != 0.0) ? (dateTimeFormatInfo.ShortDatePattern + " " + dateTimeFormatInfo.ShortTimePattern + " zzz") : (dateTimeFormatInfo.ShortDatePattern + " zzz"));
79 return dateTimeOffset.ToString(text, CultureInfo.CurrentCulture);
80 }
81 if (destinationType == typeof(InstanceDescriptor) && value is DateTimeOffset dateTimeOffset2)
82 {
83 if (dateTimeOffset2.Ticks == 0L)
84 {
85 return new InstanceDescriptor(typeof(DateTimeOffset).GetConstructor(new Type[1] { typeof(long) }), new object[1] { dateTimeOffset2.Ticks });
86 }
87 return new InstanceDescriptor(typeof(DateTimeOffset).GetConstructor(new Type[8]
88 {
89 typeof(int),
90 typeof(int),
91 typeof(int),
92 typeof(int),
93 typeof(int),
94 typeof(int),
95 typeof(int),
96 typeof(TimeSpan)
97 }), new object[8] { dateTimeOffset2.Year, dateTimeOffset2.Month, dateTimeOffset2.Day, dateTimeOffset2.Hour, dateTimeOffset2.Minute, dateTimeOffset2.Second, dateTimeOffset2.Millisecond, dateTimeOffset2.Offset });
98 }
99 return base.ConvertTo(context, culture, value, destinationType);
100 }
static CultureInfo CurrentCulture
static CultureInfo InvariantCulture
object? GetFormat(Type? formatType)

References System.culture, System.Globalization.CultureInfo.CurrentCulture, System.IFormatProvider.GetFormat(), System.Globalization.CultureInfo.InvariantCulture, System.L, System.DateTimeOffset.MinValue, System.text, and System.value.