public static DateTime ParseTime(
this DateTime baseDate,
string timeText
)
Text | Result |
---|---|
10:00 AM | 10:00 AM |
10:00 am | 10:00 AM |
10:00 p | 10:00 PM |
10:00p | 10:00 PM |
1000p | 10:00 PM |
10p | 10:00 PM |
1000 | 10:00 PM |
22:00 | 10:00 PM |
2200 | 10:00 PM |
10 | ArgumentException |
22 | ArgumentException |
22:00 PM | ArgumentException |
22:99 | ArgumentException |
var testDate = new DateTime(2010, 11, 17);
? testDate.ParseTime("6:13 PM");
// Result: 2010-11-17 18:13
ArgumentException | timeText was not a valid time. |