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

◆ ConvertTo() [1/2]

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

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 56 of file DateTimeConverter.cs.

57 {
58 if (destinationType == typeof(string) && value is DateTime dateTime)
59 {
60 if (dateTime == DateTime.MinValue)
61 {
62 return string.Empty;
63 }
64 if (culture == null)
65 {
67 }
70 {
71 if (dateTime.TimeOfDay.TotalSeconds == 0.0)
72 {
73 return dateTime.ToString("yyyy-MM-dd", culture);
74 }
75 return dateTime.ToString(culture);
76 }
77 string text = ((dateTime.TimeOfDay.TotalSeconds != 0.0) ? (dateTimeFormatInfo.ShortDatePattern + " " + dateTimeFormatInfo.ShortTimePattern) : dateTimeFormatInfo.ShortDatePattern);
78 return dateTime.ToString(text, CultureInfo.CurrentCulture);
79 }
80 if (destinationType == typeof(InstanceDescriptor) && value is DateTime dateTime2)
81 {
82 if (dateTime2.Ticks == 0L)
83 {
84 return new InstanceDescriptor(typeof(DateTime).GetConstructor(new Type[1] { typeof(long) }), new object[1] { dateTime2.Ticks });
85 }
86 return new InstanceDescriptor(typeof(DateTime).GetConstructor(new Type[7]
87 {
88 typeof(int),
89 typeof(int),
90 typeof(int),
91 typeof(int),
92 typeof(int),
93 typeof(int),
94 typeof(int)
95 }), new object[7] { dateTime2.Year, dateTime2.Month, dateTime2.Day, dateTime2.Hour, dateTime2.Minute, dateTime2.Second, dateTime2.Millisecond });
96 }
97 return base.ConvertTo(context, culture, value, destinationType);
98 }
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.DateTime.MinValue, System.Globalization.DateTimeFormatInfo.ShortDatePattern, System.Globalization.DateTimeFormatInfo.ShortTimePattern, System.text, and System.value.