Skip to content

GetNext ? issue ? #81

@TheCamel

Description

@TheCamel

Hi,
may be I am wrong somewhere
but with the following cron, 0 18 16 ? * SUN,MON,TUE,WED,THU,FRI,SAT

// I call it at <00:16:16 22/04/2025>

while (!cancellationToken.IsCancellationRequested)
{
DateTime now = DateTime.UtcNow;
DateTime? nextExecTime;
CronExpression nextExecCron = CronExpression.Parse(treatment.Cron, CronFormat.IncludeSeconds);
nextExecTime = nextExecCron.GetNextOccurrence(now.**AddMinutes**(1));

// I got <00:18:16 22/04/2025>

int delay = (int)(nextExecTime.Value - DateTime.Now).TotalMilliseconds;
 
//wait for delay

} //while

I call it at <00:16:18 TUE> + ONE MINUTE

I got <00:18:16 22/04/2025> ==> SO BACK IN TIME ??
should have <00:18:16 23/04/2025>

if i debug and wait for several minutes, i got the same result...

thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions