Closed theodorzoulias closed 10 months ago
Cronos wasn't planned to calculate occurrences after 2099 year, there's a hardcoded values, please see the following snippet. Such an upper bound is required, because it's not possible to know that some cron expression leads to an unreachable date in upfront, and we need to avoid the infinite loop in this case.
I think there should be ArgumentOutOfRangeException
thrown when start date's year is more than this hardcoded value.
In 78 years when my system fails, I'm coming back here to complain. I'll be angry, and there will probably be swearing... :wink: :stuck_out_tongue:
In 78 years, most of us will either be gone, or in wheelchairs when we are 90+ waiting for that time. Preferably with 0 care about the problem as the successors would have to worry about it.
As far as I remember the reason was to avoid iterating each second through 9999 year when something like 30th of February is specified. Case with February is more or less simple, but I'm afraid there can be other unreachable cases that's much harder to detect. May be we can increase the max date to 2200 or 2500 and throw an exception when start date is out of bounds.
or you could change it to where it selects which way to iterate based on if the chron expression is for iterating:
And then only do it based on that?
Hi! I am trying to familiarize myself with the scenarios in which the
GetNextOccurrence
can return aDateTime?
withnull
value, and I have a hard time understanding the logic behind the behavior. It seems that calculating the next occurrence for dates after the year 2100 is unsuccessful about half of the time. Here is a minimal example:Output:
Live demo.
Could you explain why the calculation fails when the month+day of the starting date is larger than the month+day in the Cron expression?
Thanks!