-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Comments
Version used is 4.0.0.0 |
Also in version 3.8.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);
.....
}
.....
The text was updated successfully, but these errors were encountered: