Shuttle.Core.Cron 10.1.4

Prefix Reserved
dotnet add package Shuttle.Core.Cron --version 10.1.4                
NuGet\Install-Package Shuttle.Core.Cron -Version 10.1.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shuttle.Core.Cron" Version="10.1.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shuttle.Core.Cron --version 10.1.4                
#r "nuget: Shuttle.Core.Cron, 10.1.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Shuttle.Core.Cron as a Cake Addin
#addin nuget:?package=Shuttle.Core.Cron&version=10.1.4

// Install Shuttle.Core.Cron as a Cake Tool
#tool nuget:?package=Shuttle.Core.Cron&version=10.1.4                

Shuttle.Core.Cron

PM> Install-Package Shuttle.Core.Cron

Provides cron expression parsing:

 ┌───────────── minute (0 - 59)
 │ ┌───────────── hour (0 - 23)
 │ │ ┌───────────── day of the month (1 - 31)
 │ │ │ ┌───────────── month (1 - 12)
 │ │ │ │ ┌───────────── day of the week (1 - 7): Sunday to Saturday 
 │ │ │ │ │                                   
 │ │ │ │ │
 │ │ │ │ │
 * * * * *

This implementation starts from the minute field (so no second). Any seconds are removed from all dates that are used.

CronExpression

public CronExpression(string expression, ISpecificationFactory specificationFactory = null) : this(expression, DateTime.Now, specificationFactory);
public CronExpression(string expression, DateTime date, ISpecificationFactory specificationFactory = null);

Creates a CronExpression instance and parses the given expression. The date specifies to root date from which to determine either the next or previous occurrence.

public DateTime NextOccurrence();
public DateTime NextOccurrence(DateTime date);

Returns the next date that would follow the given date. This is accomplished by adding 1 muinute to the relevant date. If no date is provided the root date will be used. This method also sets the root date to the result.

public DateTime GetNextOccurrence(DateTime date);

Returns the next date that would follow the given date. If the given date satisfies the required specification(s) then the date is returned as-is.

public DateTime PreviousOccurrence();
public DateTime PreviousOccurrence(DateTime date);

Returns the previous date that would precede the given date. This is accomplished by subtracting 1 muinute from the relevant date. If no date is provided the root date will be used. This method also sets the root date to the result.

public DateTime GetPreviousOccurrence(DateTime date);

Returns the previous date that would precede the given date. If the given date satisfies the required specification(s) then the date is returned as-is.

Cron Samples

Format is {minute} {hour} {day-of-month} {month} {day-of-week}

Field Options
minutes 0-59 , - * /
hours 0-23 , - * /
day-of-month 1-31 , - * ? / L W
month 1-12 or JAN-DEC , - * /
day-of-week 1-7 or SUN-SAT , - * ? / L #

If day-of-month is specified then day-of-week should be ? and vice-versa.

Examples:

* * * * * - is every minute of every hour of every day of every month
5,10-12,17/5 * * * * - minute 5, 10, 11, 12, and every 5th minute after that

Specifications

Specifications need to implement ISpecification<CronField.Candidate>.

You may pass an implementation of the ISpecificationFactory as a parameter to the CronExpression. There is a DefaultSpecificationFactory that accepts a function callback in the constructor for scenarios where an explicit ISpecificationFactory implementation may not be warranted, e.g.:

var factory = new DefaultSpecificationFactory(parameters =>
{
    return !parameters.Expression.Equals("H", StringComparison.InvariantCultureIgnoreCase) 
        ? null 
        : new Specification<CronField.Candidate>(candidate => candidate.Date.Day % 2 == 0);
});
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Shuttle.Core.Cron:

Package Downloads
Shuttle.Esb.Scheduling

Scheduling solution built on Shuttle.Esb.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
10.1.4 143 11/6/2024
10.1.3 7,449 12/1/2022
10.1.2 1,559 9/4/2022
10.1.0 15,081 2/23/2020
10.0.6 6,746 1/15/2019
10.0.5 10,742 7/4/2018
10.0.4 1,866 7/3/2018
10.0.2 2,079 2/18/2018
10.0.1 1,765 2/17/2018