1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import soon/parsetime
import std/[unittest]
import std/[times]
test "Parse single times":
check toDateTime("9") == parse("0900", "HHmm", utc())
check toDateTime("9am") == parse("0900", "HHmm", utc())
check toDateTime("9:00") == parse("0900", "HHmm", utc())
check toDateTime("9:30") == parse("0930", "HHmm", utc())
check toDateTime("09:00") == parse("0900", "HHmm", utc())
check toDateTime("09:30") == parse("0930", "HHmm", utc())
check toDateTime("9:00am") == parse("0900", "HHmm", utc())
check toDateTime("9:30pm") == parse("2130", "HHmm", utc())
check toDateTime("09:00am") == parse("0900", "HHmm", utc())
check toDateTime("09:00pm") == parse("2100", "HHmm", utc())
check toDateTime("09:30am") == parse("0930", "HHmm", utc())
check toDateTime("09:30pm") == parse("2130", "HHmm", utc())
check toDateTime("17") == parse("1700", "HHmm", utc())
check toDateTime("24") == parse("0000", "HHmm", utc())
check toDateTime("17:00") == parse("1700", "HHmm", utc())
check toDateTime("12:00") == parse("1200", "HHmm", utc())
check toDateTime("24:00") == parse("0000", "HHmm", utc())
check toDateTime("00:00") == parse("0000", "HHmm", utc())
check toDateTime("01:00") == parse("0100", "HHmm", utc())
test "Parse time ranges":
check toDateTime("9-1am") == parse("2100", "HHmm", utc())
check toDateTime("9am-1am") == parse("0900", "HHmm", utc())
check toDateTime("9:00-1:00am") == parse("2100", "HHmm", utc())
check toDateTime("9:30-1:30am") == parse("2130", "HHmm", utc())
check toDateTime("09:00-01:00am") == parse("2100", "HHmm", utc())
check toDateTime("09:30-01:30am") == parse("2130", "HHmm", utc())
check toDateTime("9:00am-1:00am") == parse("0900", "HHmm", utc())
check toDateTime("9:30pm-01:00am") == parse("2130", "HHmm", utc())
check toDateTime("09:00am-01:00am") == parse("0900", "HHmm", utc())
check toDateTime("09:00pm-01:00am") == parse("2100", "HHmm", utc())
check toDateTime("09:30am-01:30am") == parse("0930", "HHmm", utc())
check toDateTime("09:30pm-01:30am") == parse("2130", "HHmm", utc())
check toDateTime("17-1am") == parse("1700", "HHmm", utc())
check toDateTime("17:00-1:00am") == parse("1700", "HHmm", utc())
check toDateTime("12:00-1:00am") == parse("0000", "HHmm", utc())
check toDateTime("12-1:00am") == parse("0000", "HHmm", utc())
check toDateTime("00:00-01:00am") == parse("0000", "HHmm", utc())
check toDateTime("11-12pm") == parse("1100", "HHmm", utc())
check toDateTime("11-12am") == parse("2300", "HHmm", utc())
check toDateTime("11-12") == parse("1100", "HHmm", utc())
check toDateTime("9pm-12am") == parse("2100", "HHmm", utc())
check toDateTime("11:00-13:00") == parse("1100", "HHmm", utc())
check toDateTime("12:00-13:00") == parse("1200", "HHmm", utc())
check toDateTime("11:00-24:00") == parse("1100", "HHmm", utc())
check toDateTime("23:00-24:00") == parse("2300", "HHmm", utc())
check toDateTime("24:00-23:00") == parse("0000", "HHmm", utc())
|