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

CronExpresion.GetTimeAfter caught exception #2330

Open
lynnz11 opened this issue Apr 22, 2024 · 2 comments
Open

CronExpresion.GetTimeAfter caught exception #2330

lynnz11 opened this issue Apr 22, 2024 · 2 comments

Comments

@lynnz11
Copy link

lynnz11 commented Apr 22, 2024

Describe the bug

CronExpression cronExpression = new CronExpression("0 0 12 31W * ?");
DateTime cal = new DateTime(2024, 1, 31, 12, 0, 0).ToUniversalTime();
var nextFireTime = cronExpression.GetTimeAfter((DateTimeOffset)cal);

The exception: System.ArgumentOutOfRangeException
Year, Month, and Day parameters describe an un-representable DateTime.

Version used

3.8.1

To Reproduce

See Describe the bug

Expected behavior

No exception.

Additional context
CronExpression Class line 1747
private SortedSet CalculateDaysOfMonth(DateTimeOffset dt)
{
if.....
//line 1510
else if (nearestWeekday) //AND not lastDay
{
var lastDayOfMonth = GetLastDayOfMonth(dt.Month, dt.Year);
// current
var day = daysOfMonth.Min;
// update to following
var day = Math.Min(daysOfMonth.Min, lastDayOfMonth);
var tcal = new DateTimeOffset(dt.Year, dt.Month, day, 0, 0, 0, dt.Offset);
.....
}
.....

@lynnz11
Copy link
Author

lynnz11 commented Apr 24, 2024

Version used is 4.0.0.0

@lynnz11
Copy link
Author

lynnz11 commented May 1, 2024

Also in version 3.8.1

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