You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I have a problem getting next occurrence time or i just miss something in Cronos documentation.
Problem:
User can set scheduler, which is done with the cron expression. User can set date and time and interval. For example 1.2.2012 15:00:00 every two days. But the date doesn't change often, only when user set new time or interval, what means if today is 20.2.2012 12:00:00, then GetNextOccurrence() get the 3.2.2012 15:00:00 as result, but i want to get 21.2.2012, which is the next relevant run time.
Workaround:
var occs = expression.GetOccurrences(schedule.Time, DateTime.UtcNow, TimeZoneInfo.Local).ToList();
job.NextRunTime = expression.GetNextOccurrence(occs.Last(), TimeZoneInfo.Local);
I just get all occurrences till today and then i use last one to get the ACTUAL next one.
Does it make sense to have a function like: GetNextOccurrenceBasedOnDateTimeNow(...)?
Thank You
The text was updated successfully, but these errors were encountered:
So schedule.Time is that user entered initial start date and the cron expression is something like 0 0 */2 * * In that case when you use GetNextOccurrence() you will have to supply the last occurrence as input parameter to get the next occurrence. Th first time, ie. when the user sets this up you use the schedule.Time as last occurrence and the next one is calculated. You could then store that occurrence in schedule.Time, unles you want to keep that value, in that case you will have to store it in another variable/field.
Your workaround also solves this but, as you stated, in a sub-optimal way.
I don't think this is a bug, it's just the way cron works, you supply it a starting point date and a cron expression and it calculates the next occurrence according to the cron expression.
Hi. I have a problem getting next occurrence time or i just miss something in Cronos documentation.
Problem:
User can set scheduler, which is done with the cron expression. User can set date and time and interval. For example 1.2.2012 15:00:00 every two days. But the date doesn't change often, only when user set new time or interval, what means if today is 20.2.2012 12:00:00, then GetNextOccurrence() get the 3.2.2012 15:00:00 as result, but i want to get 21.2.2012, which is the next relevant run time.
Workaround:
I just get all occurrences till today and then i use last one to get the ACTUAL next one.
Does it make sense to have a function like: GetNextOccurrenceBasedOnDateTimeNow(...)?
Thank You
The text was updated successfully, but these errors were encountered: