Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Allow leading zero in cronline #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions cronexpr_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,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,
}
)
Expand Down
11 changes: 11 additions & 0 deletions cronexpr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,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
}

Expand Down