public static FromHourMinSec ( Byte Hour, Byte Minute, Byte Second ) : |
||
Hour | Byte | The hour. |
Minute | Byte | The minute |
Second | Byte | The second. |
Résultat |
/// <summary> /// Try to parse the given text as time. /// </summary> /// <param name="Text">A text representation of the time.</param> /// <param name="Time">The parsed time.</param> public static Boolean TryParse(String Text, out Time Time) { var Fragments = Text.Trim().Split(':'); Byte Hour = 0; Byte Minute = 0; Byte Second = 0; Time = Time.FromHour(0); if (Fragments.Length == 1) { if (!Byte.TryParse(Fragments[0], out Hour)) { return(false); } Time = Time.FromHour(Hour); return(true); } else if (Fragments.Length == 2) { if (!Byte.TryParse(Fragments[0], out Hour)) { return(false); } if (!Byte.TryParse(Fragments[1], out Minute)) { return(false); } Time = Time.FromHourMin(Hour, Minute); return(true); } else if (Fragments.Length == 3) { if (!Byte.TryParse(Fragments[0], out Hour)) { return(false); } if (!Byte.TryParse(Fragments[1], out Minute)) { return(false); } if (!Byte.TryParse(Fragments[2], out Second)) { return(false); } Time = Time.FromHourMinSec(Hour, Minute, Second); return(true); } return(false); }
/// <summary> /// Try to parse the given text as time. /// </summary> /// <param name="Text">A text representation of the time.</param> /// <param name="Time">The parsed time.</param> public static Boolean TryParse(String Text, out Time Time) { var Fragments = Text.Trim().Split(':'); Byte Hour = 0; Byte Minute = 0; Byte Second = 0; Time = Time.FromHour(0); if (Fragments.Length == 1) { if (!Byte.TryParse(Fragments[0], out Hour)) return false; Time = Time.FromHour(Hour); return true; } else if (Fragments.Length == 2) { if (!Byte.TryParse(Fragments[0], out Hour)) return false; if (!Byte.TryParse(Fragments[1], out Minute)) return false; Time = Time.FromHourMin(Hour, Minute); return true; } else if (Fragments.Length == 3) { if (!Byte.TryParse(Fragments[0], out Hour)) return false; if (!Byte.TryParse(Fragments[1], out Minute)) return false; if (!Byte.TryParse(Fragments[2], out Second)) return false; Time = Time.FromHourMinSec(Hour, Minute, Second); return true; } return false; }