Skip to content

Commit

Permalink
Fix a bug where months are padded with 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Sep 1, 2020
1 parent d968249 commit 8cee125
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cronexpr_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ 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,
Expand Down
11 changes: 11 additions & 0 deletions cronexpr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ var crontests = []crontest{
},
},

// Zero padded months
{
"0 0 * 04 * *",
"Mon 2006-01-02 15:04",
[]crontimes{
{"2013-09-02 00:00:00", "Tue 2014-04-01 00:00"},
{"2014-04-03 03:00:00", "Fri 2014-04-04 00:00"},
{"2014-08-15 00:00:00", "Wed 2015-04-01 00:00"},
},
},

// TODO: more tests
}

Expand Down

0 comments on commit 8cee125

Please sign in to comment.