Skip to content

Commit 1ec85d6

Browse files
committed
week iteration bug fixed.
1 parent 26cb837 commit 1ec85d6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

crontools/crontab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def _weekday_iter(self, year: int, month: int, start_day: int = 1) -> Iterator[i
334334
curr_weekday = calendar.weekday(year, month, curr_day) + 1
335335
weekday_iter = self._weekday_field.iter(start_from=curr_weekday)
336336

337-
for _ in range(5):
337+
for _ in range(6):
338338
for weekday in weekday_iter:
339339
curr_day += (weekday - curr_weekday)
340340
curr_weekday += (weekday - curr_weekday)

tests/test_crontab.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,26 @@ def test_cron_iterator(expr, result, years_ext, seconds_ext):
412412
False,
413413
False,
414414
),
415+
(
416+
'0 0 1-31 * *',
417+
dt.datetime(year=2020, month=1, day=1, tzinfo=dt.timezone.utc),
418+
[
419+
dt.datetime(year=2020, month=1, day=1, tzinfo=dt.timezone.utc) + dt.timedelta(days=day)
420+
for day in range(368)
421+
],
422+
False,
423+
False,
424+
),
425+
(
426+
'0 0 * * MON-SUN',
427+
dt.datetime(year=2020, month=1, day=1, tzinfo=dt.timezone.utc),
428+
[
429+
dt.datetime(year=2020, month=1, day=1, tzinfo=dt.timezone.utc) + dt.timedelta(days=day)
430+
for day in range(367*7)
431+
],
432+
False,
433+
False,
434+
),
415435
],
416436
)
417437
@freezegun.freeze_time('2020-01-01 00:00:00.000Z+00:00')

0 commit comments

Comments
 (0)