Cleanup Timestamp ctor(String)
This commit is contained in:
parent
9bd25a1aa1
commit
7d1133ff9c
|
@ -97,31 +97,39 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
return new Timestamp(str).Valid;
|
return new Timestamp(str).Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly byte MIN;
|
||||||
|
|
||||||
|
public readonly byte SEC;
|
||||||
|
|
||||||
|
public readonly byte FRAC;
|
||||||
|
|
||||||
|
public readonly bool Valid;
|
||||||
|
|
||||||
|
public readonly bool Negative;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// creates a timestamp from a string in the form mm:ss:ff
|
/// creates a timestamp from a string in the form mm:ss:ff
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Timestamp(string str)
|
public Timestamp(string str)
|
||||||
{
|
{
|
||||||
if (str.Length != 8) goto BOGUS;
|
MIN = SEC = FRAC = 0;
|
||||||
if (str[0] < '0' || str[0] > '9') goto BOGUS;
|
Negative = false;
|
||||||
if (str[1] < '0' || str[1] > '9') goto BOGUS;
|
|
||||||
if (str[2] != ':') goto BOGUS;
|
Valid = false;
|
||||||
if (str[3] < '0' || str[3] > '9') goto BOGUS;
|
if (str.Length != 8) return;
|
||||||
if (str[4] < '0' || str[4] > '9') goto BOGUS;
|
if (str[0] < '0' || str[0] > '9') return;
|
||||||
if (str[5] != ':') goto BOGUS;
|
if (str[1] < '0' || str[1] > '9') return;
|
||||||
if (str[6] < '0' || str[6] > '9') goto BOGUS;
|
if (str[2] != ':') return;
|
||||||
if (str[7] < '0' || str[7] > '9') goto BOGUS;
|
if (str[3] < '0' || str[3] > '9') return;
|
||||||
|
if (str[4] < '0' || str[4] > '9') return;
|
||||||
|
if (str[5] != ':') return;
|
||||||
|
if (str[6] < '0' || str[6] > '9') return;
|
||||||
|
if (str[7] < '0' || str[7] > '9') return;
|
||||||
|
Valid = true;
|
||||||
|
|
||||||
MIN = (byte)((str[0] - '0') * 10 + (str[1] - '0'));
|
MIN = (byte)((str[0] - '0') * 10 + (str[1] - '0'));
|
||||||
SEC = (byte)((str[3] - '0') * 10 + (str[4] - '0'));
|
SEC = (byte)((str[3] - '0') * 10 + (str[4] - '0'));
|
||||||
FRAC = (byte)((str[6] - '0') * 10 + (str[7] - '0'));
|
FRAC = (byte)((str[6] - '0') * 10 + (str[7] - '0'));
|
||||||
Valid = true;
|
|
||||||
Negative = false;
|
|
||||||
return;
|
|
||||||
BOGUS:
|
|
||||||
MIN = SEC = FRAC = 0;
|
|
||||||
Valid = false;
|
|
||||||
Negative = false;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -129,9 +137,6 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Value => !Valid ? "--:--:--" : $"{(Negative ? '-' : '+')}{MIN:D2}:{SEC:D2}:{FRAC:D2}";
|
public string Value => !Valid ? "--:--:--" : $"{(Negative ? '-' : '+')}{MIN:D2}:{SEC:D2}:{FRAC:D2}";
|
||||||
|
|
||||||
public readonly byte MIN, SEC, FRAC;
|
|
||||||
public readonly bool Valid, Negative;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The fully multiplied out flat-address Sector number
|
/// The fully multiplied out flat-address Sector number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue