diff --git a/src/BizHawk.Common/BizDateTimeConverter.cs b/src/BizHawk.Common/BizDateTimeConverter.cs new file mode 100644 index 0000000000..cff5fcc3a2 --- /dev/null +++ b/src/BizHawk.Common/BizDateTimeConverter.cs @@ -0,0 +1,15 @@ +using System; +using System.ComponentModel; +using System.Globalization; + +namespace BizHawk.Common +{ + public class BizDateTimeConverter : DateTimeConverter + { + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) + { + if (value is not DateTime d || destinationType != typeof(string)) throw new NotSupportedException("can only do DateTime --> string"); + return d.ToString(); + } + } +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.ISettable.cs index 2f19db0fdc..eed9f9743b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.ISettable.cs @@ -163,6 +163,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA [DisplayName("RTC Initial Time")] [Description("The initial time of emulation. Only relevant when a game has an RTC chip and \"RTC Use Real Time\" is false.")] [DefaultValue(typeof(DateTime), "2010-01-01")] + [TypeConverter(typeof(BizDateTimeConverter))] public DateTime RTCInitialTime { get; set; } [DisplayName("Save Type")] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.ISettable.cs index 7b926f03a9..b077eda597 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.ISettable.cs @@ -91,6 +91,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS [DisplayName("Initial Time")] [Description("Initial time of emulation.")] [DefaultValue(typeof(DateTime), "2000-01-01")] + [TypeConverter(typeof(BizDateTimeConverter))] public DateTime InitialTime { get => _initaltime; diff --git a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs index 1a7a240c55..a7da8d0797 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs @@ -88,10 +88,12 @@ namespace BizHawk.Emulation.Cores.WonderSwan [DisplayName("Initial Time")] [Description("Initial time of emulation. Only relevant when UseRealTime is false.")] [DefaultValue(typeof(DateTime), "2010-01-01")] + [TypeConverter(typeof(BizDateTimeConverter))] public DateTime InitialTime { get; set; } [Description("Your birthdate. Stored in EEPROM and used by some games.")] [DefaultValue(typeof(DateTime), "1968-05-13")] + [TypeConverter(typeof(BizDateTimeConverter))] public DateTime BirthDate { get; set; } [Description("True to emulate a color system.")]