Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug: 0 12 1-31 * 1 is parsed incorrectly #284

Open
MaxHam opened this issue Sep 8, 2022 · 1 comment
Open

Possible bug: 0 12 1-31 * 1 is parsed incorrectly #284

MaxHam opened this issue Sep 8, 2022 · 1 comment
Labels

Comments

@MaxHam
Copy link

MaxHam commented Sep 8, 2022

Hi,
the expression 0 12 1-31 * 1 should output dates that match every day-of-month and day-of-week since both fields are not *, but it outputs the same as 0 12 * * 1 , which should only match the day-of-week, since day-of-month is *.

The output is:

  • Mon, Sep 12, 2022, 14:00
  • Mon, Sep 19, 2022, 14:00
  • Mon, Sep 26, 2022, 14:00
  • Mon, Oct 03, 2022, 14:00
  • Mon, Oct 10, 2022, 14:00
  • Mon, Oct 17, 2022, 14:00

On the other hand an expression like 0 12 1 * 0-6 triggers every day, while the expression 0 12 1 * * triggers only on the first day-of-month. I think this behaviour is the correct one and I am asking why the behaviour is asynchronous between day-of-week and day-of-month being either * or 1-31, 0-6.

@MichaelLeeHobbs
Copy link

MichaelLeeHobbs commented Apr 29, 2023

Nasty bug.

var isDayOfMonthWildcardMatch = this.fields.dayOfMonth.length >= CronExpression.daysInMonth[currentDate.getMonth()];  // this causes the engine to treat 1-31 as a wild card search when it isn't
var isDayOfWeekWildcardMatch = this.fields.dayOfWeek.length === CronExpression.constraints[5].max - CronExpression.constraints[5].min + 1;

I'm working on a fix in the refactored version I'm working on. The isDayOfMonthWildcardMatch incorrectly treats 1-31 as a wild card match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants