mariusbancila / croncpp

A C++11/14/17 header-only cross-platform library for handling CRON expressions
MIT License
236 stars 68 forks source link

Bug in handling cronspecs with 31-day months #30

Open bahmanrafatjoo opened 2 years ago

bahmanrafatjoo commented 2 years ago

Looks like there's a bug with handing cronspecs with some 31-day months. The tests don't fail for every 31-day month but where they do the failure is different depending on the input. I'm fairly sure I've the correct input format.

Passing test:

check_next("0 25 23 31 10 ?", "2011-09-22 14:20:00", "2011-10-31 23:25:00");

Failing test 1:

check_next("0 25 23 31 7 ?", "2011-09-22 14:20:00", "2012-07-31 23:25:00");

image

Failing test 2:

check_next("0 25 23 31 8 ?", "2011-09-22 14:20:00", "2012-08-31 23:25:00");

image

I'll try and go through the code to see if I can identify the cause but thought I'd post this in case some wiser heads can assist.

bahmanrafatjoo commented 1 year ago

I have a proposed fix which I'll submit as a PR.