Interface ICronScheduler
Provides cron-based scheduling capabilities with timezone awareness.
public interface ICronScheduler
- Extension Methods
Methods
GetPreviousOccurrence(ICronExpression, DateTimeOffset)
Calculates when a cron expression should have last run.
DateTimeOffset? GetPreviousOccurrence(ICronExpression cronExpression, DateTimeOffset from)
Parameters
cronExpressionICronExpressionThe cron expression.
fromDateTimeOffsetThe time from which to calculate backwards.
Returns
- DateTimeOffset?
The previous occurrence time, or null if there is no previous occurrence.
Parse(string, TimeZoneInfo?)
Parses a cron expression string into an ICronExpression.
ICronExpression Parse(string expression, TimeZoneInfo? timeZone = null)
Parameters
expressionstringThe cron expression string.
timeZoneTimeZoneInfoThe 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.
bool TryParse(string expression, out ICronExpression? cronExpression)
Parameters
expressionstringThe cron expression to validate.
cronExpressionICronExpressionWhen 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.
bool TryParse(string expression, TimeZoneInfo timeZone, out ICronExpression? cronExpression)
Parameters
expressionstringThe cron expression to validate.
timeZoneTimeZoneInfoThe timezone for the expression.
cronExpressionICronExpressionThe 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.
bool WouldTriggerAt(ICronExpression cronExpression, DateTimeOffset time)
Parameters
cronExpressionICronExpressionThe cron expression.
timeDateTimeOffsetThe time to check.
Returns
- bool
True if the expression would trigger at the specified time.