HangfireIO / Cronos

A fully-featured .NET library for working with Cron expressions. Built with time zones in mind and intuitively handles daylight saving time transitions
MIT License
1.01k stars 118 forks source link

GetOccurrences method to calculate the next occurrences based on the from date specified. #7

Closed DivyaBharathi021 closed 6 years ago

DivyaBharathi021 commented 6 years ago

I need the GetOccurrences method to calculate the next occurrences based on the from date,

Eg: My cron expression is ' Occurs on day 1 of every 3 months' and from date is 'Feb 20 2018' , then the occurences should be

But the current behaviour is always taking the default date as

Need help to figure out the issue

odinserj commented 6 years ago

Schedule calculation using cron expression doesn't depend on start or end date, its output is always stable. This means it will return the same values for the same cron expression, regardless the specified boundaries. It performs calculation by iterating through the calendar date/time, checking each date/time value (though in reality, more optimized algorithm is used).

In particular, your 0 0 1 */3 * expression will be equal to the 0 0 1 1,4,7,10 *, always giving the Jan, 1 00:00, Apr 1, 00:00, Jul 1, 00:00 and Oct 1, 00:00 occurrences.