elsa-core/src/modules/Elsa.Scheduling/Services/CronosCronParser.cs
Sipke Schoorstra 8fb797eaeb
Remove Elsa.Expressions.Dsl module and related DSL features
This commit completely removes the Elsa.Expressions.Dsl module, including all associated features, services, models, and dependencies. The DSL functionality, including its custom activities and integration options, has been fully eliminated from the project.
2025-06-02 21:52:10 +02:00

28 lines
779 B
C#

using Cronos;
using Elsa.Common;
namespace Elsa.Scheduling.Services;
/// <summary>
/// A cron parser that uses Cronos.
/// </summary>
public class CronosCronParser : ICronParser
{
private readonly ISystemClock _systemClock;
/// <summary>
/// Initializes a new instance of the <see cref="CronosCronParser"/> class.
/// </summary>
public CronosCronParser(ISystemClock systemClock)
{
_systemClock = systemClock;
}
/// <inheritdoc />
public DateTimeOffset GetNextOccurrence(string expression)
{
var parsedExpression = CronExpression.Parse(expression, CronFormat.IncludeSeconds);
var now = _systemClock.UtcNow;
return parsedExpression.GetNextOccurrence(now, TimeZoneInfo.Utc).GetValueOrDefault();
}
}