Table of Contents

Class CronScheduler

Namespace
Excalibur.Dispatch.Delivery
Assembly
Excalibur.Dispatch.dll

Default implementation of ICronScheduler with timezone awareness.

public sealed class CronScheduler : ICronScheduler
Inheritance
CronScheduler
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the CronScheduler class.

Constructors

CronScheduler(IOptions<CronScheduleOptions>, ILogger<CronScheduler>)

Default implementation of ICronScheduler with timezone awareness.

public CronScheduler(IOptions<CronScheduleOptions> options, ILogger<CronScheduler> logger)

Parameters

options IOptions<CronScheduleOptions>

The cron schedule options.

logger ILogger<CronScheduler>

The logger.

Remarks

Initializes a new instance of the CronScheduler class.

Methods

GetMissedExecutions(ICronExpression, DateTimeOffset, DateTimeOffset)

Calculates missed executions for a cron expression.

public IEnumerable<DateTimeOffset> GetMissedExecutions(ICronExpression cronExpression, DateTimeOffset lastRun, DateTimeOffset now)

Parameters

cronExpression ICronExpression

The cron expression.

lastRun DateTimeOffset

The last successful run time.

now DateTimeOffset

The current time.

Returns

IEnumerable<DateTimeOffset>

List of missed execution times.

GetPreviousOccurrence(ICronExpression, DateTimeOffset)

Calculates when a cron expression should have last run.

public DateTimeOffset? GetPreviousOccurrence(ICronExpression cronExpression, DateTimeOffset from)

Parameters

cronExpression ICronExpression

The cron expression.

from DateTimeOffset

The time from which to calculate backwards.

Returns

DateTimeOffset?

The previous occurrence time, or null if there is no previous occurrence.

HandleDaylightSavingTransition(DateTimeOffset, TimeZoneInfo)

Handles daylight saving time transitions for a scheduled time.

public DateTimeOffset HandleDaylightSavingTransition(DateTimeOffset scheduledTime, TimeZoneInfo timeZone)

Parameters

scheduledTime DateTimeOffset

The local wall-clock fields to interpret in timeZone. Its existing offset is preserved when no adjustment is needed.

timeZone TimeZoneInfo

The timezone.

Returns

DateTimeOffset

A checked valid local time after a gap, or the earliest UTC instant for an ambiguous local time. Disabled adjustment and valid times return the original value.

Remarks

This explicit helper does not alter parsed cron evaluation, which delegates transition handling to Cronos. Gap resolution searches at tick precision within a local-date bracket; it does not guarantee the earliest valid tick for every historical rule representation. If adjustment fails, the error is logged and the original value is returned.

Parse(string, TimeZoneInfo?)

Parses a cron expression string into an ICronExpression.

public ICronExpression Parse(string expression, TimeZoneInfo? timeZone = null)

Parameters

expression string

The cron expression string.

timeZone TimeZoneInfo

The timezone for evaluating the expression. If null, uses the system's local timezone.

Returns

ICronExpression

A parsed cron expression.

TryParse(string, out ICronExpression?)

Validates whether a cron expression string is valid.

public bool TryParse(string expression, out ICronExpression? cronExpression)

Parameters

expression string

The cron expression to validate.

cronExpression ICronExpression

When this method returns, contains the parsed cron expression if the input is valid; otherwise, null.

Returns

bool

True if the expression is valid; otherwise, false.

TryParse(string, TimeZoneInfo, out ICronExpression?)

Validates whether a cron expression string is valid for a specific timezone.

public bool TryParse(string expression, TimeZoneInfo timeZone, out ICronExpression? cronExpression)

Parameters

expression string

The cron expression to validate.

timeZone TimeZoneInfo

The timezone for the expression.

cronExpression ICronExpression

The parsed expression if valid.

Returns

bool

True if the expression is valid; otherwise, false.

WouldTriggerAt(ICronExpression, DateTimeOffset)

Determines if a cron expression would trigger at a specific time.

public bool WouldTriggerAt(ICronExpression cronExpression, DateTimeOffset time)

Parameters

cronExpression ICronExpression

The cron expression.

time DateTimeOffset

The time to check.

Returns

bool

True if the expression would trigger at the specified time.