Skip to content

Commit a5b9ff1

Browse files
author
Mahmood Ali
authored
Merge pull request #3 from hashicorp/b-month-zero-padding
Fix case where month is padded with 0
2 parents d968249 + 8cee125 commit a5b9ff1

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

cronexpr_parse.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ var (
7878
"2090": 2090, "2091": 2091, "2092": 2092, "2093": 2093, "2094": 2094, "2095": 2095, "2096": 2096, "2097": 2097, "2098": 2098, "2099": 2099,
7979
}
8080
monthTokens = map[string]int{
81-
`1`: 1, `jan`: 1, `january`: 1,
82-
`2`: 2, `feb`: 2, `february`: 2,
83-
`3`: 3, `mar`: 3, `march`: 3,
84-
`4`: 4, `apr`: 4, `april`: 4,
85-
`5`: 5, `may`: 5,
86-
`6`: 6, `jun`: 6, `june`: 6,
87-
`7`: 7, `jul`: 7, `july`: 7,
88-
`8`: 8, `aug`: 8, `august`: 8,
89-
`9`: 9, `sep`: 9, `september`: 9,
81+
`1`: 1, `01`: 1, `jan`: 1, `january`: 1,
82+
`2`: 2, `02`: 2, `feb`: 2, `february`: 2,
83+
`3`: 3, `03`: 3, `mar`: 3, `march`: 3,
84+
`4`: 4, `04`: 4, `apr`: 4, `april`: 4,
85+
`5`: 5, `05`: 5, `may`: 5,
86+
`6`: 6, `06`: 6, `jun`: 6, `june`: 6,
87+
`7`: 7, `07`: 7, `jul`: 7, `july`: 7,
88+
`8`: 8, `08`: 8, `aug`: 8, `august`: 8,
89+
`9`: 9, `09`: 9, `sep`: 9, `september`: 9,
9090
`10`: 10, `oct`: 10, `october`: 10,
9191
`11`: 11, `nov`: 11, `november`: 11,
9292
`12`: 12, `dec`: 12, `december`: 12,

cronexpr_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ var crontests = []crontest{
209209
},
210210
},
211211

212+
// Zero padded months
213+
{
214+
"0 0 * 04 * *",
215+
"Mon 2006-01-02 15:04",
216+
[]crontimes{
217+
{"2013-09-02 00:00:00", "Tue 2014-04-01 00:00"},
218+
{"2014-04-03 03:00:00", "Fri 2014-04-04 00:00"},
219+
{"2014-08-15 00:00:00", "Wed 2015-04-01 00:00"},
220+
},
221+
},
222+
212223
// TODO: more tests
213224
}
214225

0 commit comments

Comments
 (0)