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

Error in ChonExpression DayOfWeek pattern #2273

Open
zorgoz opened this issue Feb 6, 2024 · 0 comments
Open

Error in ChonExpression DayOfWeek pattern #2273

zorgoz opened this issue Feb 6, 2024 · 0 comments

Comments

@zorgoz
Copy link

zorgoz commented Feb 6, 2024

Describe the bug

If containing a "day of week" part, the expression is not satisfied by a timestamp that should satisfy it. On the other hand, the same timestamp satisfies expressions with specific "day of week" part, that should not be satisfied by it. The GetNextValidTimeAfter method return a timestamp that should not satisfy the pattern, but it does.

Version used

3.8.0

To Reproduce

var dto = DateTimeOffset.Parse("2024.02.06 09:35:00");
Console.WriteLine(dto.ToString("dddd")); // yields: Tuesday

var co2 = new CronExpression("0 35 09 ? * 2");
Console.WriteLine(co2.IsSatisfiedBy(dto)); // yields: FALSE, but is should return TRUE

var next = co2.GetNextValidTimeAfter(dto); // it should give a date that is Tuesday
Console.WriteLine(next.Value.ToString("dddd")); // yieldy: Monday
Console.WriteLine(co2.IsSatisfiedBy(next.Value)); // yields: TRUE, should return FALSE

var co3 = new CronExpression("0 35 09 ? * 3"); // note: should match Wednesday only
Console.WriteLine(co3.IsSatisfiedBy(dto)); // yields: TRUE, should return FALSE

var co4 = new CronExpression("0 35 09 ? * 1"); // note: should match Monday only
Console.WriteLine(co4.IsSatisfiedBy(next.Value)); // yields: FALSE, although that's a Monday

Expected behavior

The pattern should be satisfied by dates that are on the proper days of the week. The next valid date should also match the pattern.

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

No branches or pull requests

1 participant