fix date time display ()

* fix date time display

* Use ISO8601, fix nullability, improve validation

* Should probably override all of them to be consistent

* use local time format here

Co-authored-by: James Groom <OSSYoshiRulz+GitHub@gmail.com>
This commit is contained in:
CasualPokePlayer 2021-10-29 21:48:45 -07:00 committed by GitHub
parent 84b55d2af4
commit 77916cfa2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 0 deletions
src
BizHawk.Common
BizHawk.Emulation.Cores/Consoles

View File

@ -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();
}
}
}

View File

@ -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")]

View File

@ -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;

View File

@ -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.")]