diff --git a/cronexpr_parse.go b/cronexpr_parse.go index a9fe746..362cb10 100644 --- a/cronexpr_parse.go +++ b/cronexpr_parse.go @@ -76,27 +76,27 @@ var ( "2090": 2090, "2091": 2091, "2092": 2092, "2093": 2093, "2094": 2094, "2095": 2095, "2096": 2096, "2097": 2097, "2098": 2098, "2099": 2099, } monthTokens = map[string]int{ - `1`: 1, `jan`: 1, `january`: 1, - `2`: 2, `feb`: 2, `february`: 2, - `3`: 3, `mar`: 3, `march`: 3, - `4`: 4, `apr`: 4, `april`: 4, - `5`: 5, `may`: 5, - `6`: 6, `jun`: 6, `june`: 6, - `7`: 7, `jul`: 7, `july`: 7, - `8`: 8, `aug`: 8, `august`: 8, - `9`: 9, `sep`: 9, `september`: 9, + `1`: 1, `01`: 1, `jan`: 1, `january`: 1, + `2`: 2, `02`: 2, `feb`: 2, `february`: 2, + `3`: 3, `03`: 3, `mar`: 3, `march`: 3, + `4`: 4, `04`: 4, `apr`: 4, `april`: 4, + `5`: 5, `05`: 5, `may`: 5, + `6`: 6, `06`: 6, `jun`: 6, `june`: 6, + `7`: 7, `07`: 7, `jul`: 7, `july`: 7, + `8`: 8, `08`: 8, `aug`: 8, `august`: 8, + `9`: 9, `09`: 9, `sep`: 9, `september`: 9, `10`: 10, `oct`: 10, `october`: 10, `11`: 11, `nov`: 11, `november`: 11, `12`: 12, `dec`: 12, `december`: 12, } dowTokens = map[string]int{ - `0`: 0, `sun`: 0, `sunday`: 0, - `1`: 1, `mon`: 1, `monday`: 1, - `2`: 2, `tue`: 2, `tuesday`: 2, - `3`: 3, `wed`: 3, `wednesday`: 3, - `4`: 4, `thu`: 4, `thursday`: 4, - `5`: 5, `fri`: 5, `friday`: 5, - `6`: 6, `sat`: 6, `saturday`: 6, + `0`: 0, `00`: 0, `sun`: 0, `sunday`: 0, + `1`: 1, `01`: 1, `mon`: 1, `monday`: 1, + `2`: 2, `02`: 2, `tue`: 2, `tuesday`: 2, + `3`: 3, `03`: 3, `wed`: 3, `wednesday`: 3, + `4`: 4, `04`: 4, `thu`: 4, `thursday`: 4, + `5`: 5, `05`: 5, `fri`: 5, `friday`: 5, + `6`: 6, `06`: 6, `sat`: 6, `saturday`: 6, `7`: 0, } ) diff --git a/cronexpr_test.go b/cronexpr_test.go index 6ccf7ab..fb15d7c 100644 --- a/cronexpr_test.go +++ b/cronexpr_test.go @@ -194,6 +194,17 @@ var crontests = []crontest{ }, }, + { // Zero leading values + "00 01 03 07 *", + "Mon 2006-01-02 15:04", + []crontimes{ + {"2013-01-01 00:00:00", "Wed 2013-07-03 01:00"}, + {"2014-01-28 00:00:00", "Thu 2014-07-03 01:00"}, + {"2013-12-30 00:30:00", "Thu 2014-07-03 01:00"}, + {"2015-07-03 02:01:00", "Sun 2016-07-03 01:00"}, + }, + }, + // TODO: more tests }