RM.CronExpression 1.0.0

dotnet add package RM.CronExpression --version 1.0.0                
NuGet\Install-Package RM.CronExpression -Version 1.0.0                
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="RM.CronExpression" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RM.CronExpression --version 1.0.0                
#r "nuget: RM.CronExpression, 1.0.0"                
#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 RM.CronExpression as a Cake Addin
#addin nuget:?package=RM.CronExpression&version=1.0.0

// Install RM.CronExpression as a Cake Tool
#tool nuget:?package=RM.CronExpression&version=1.0.0                

What is Cron Expressions?

Cron expressions are used to configure instances of CronTrigger, a subclass of org.quartz.Trigger. A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule.

What is RMCronExpression?

The easiest way to create a cron expression without the need to get familiar with its details and complications

How do I get started?

First, configure AutoMapper to know what types you want to map, in the startup of your application:

//Every second
var cronExpression = new CronExpressionBuilder().Build();

// result => "* * * * * * *"
//At 38 seconds past the minute, at 15 and 45 minutes past the hour, at 04:00 PM
var cronExpression = new CronExpressionBuilder()
                        .Hours(16)
                        .Minutes(15,45)
                        .Seconds(38)
                        .Build();

// result => "38 15,45 16 * * * *"
//Every second, every 3 months
var cronExpression = new CronExpressionBuilder()
                              .Every(3, CE.Month)
                              .Build();

// result => "* * * * 1/3 * *"
//Every second, between 04:00 AM and 04:59 AM, on day 22 and 28 of the month, and on Sunday and Friday
var cronExpression = new CronExpressionBuilder()
                              .Hours(4)
                              .DaysOfMonth(22, 28)
                              .DaysOfWeek(DayOfWeek.Sunday,DayOfWeek.Friday)
                              .Build();

// result => "* * 4 22,28 * 0,5 *"
//At 0, 23, and [31 through 54] seconds past the minute, at 1, 2, and 3 minutes past the hour, at 12:00 AM, 02:00 PM, and aN:00 AM through 10:59 PM, every 5 months, June through December
var cronExpression = new CronExpressionBuilder()
                            .Seconds(0, 23)
                            .SecondsRange(31, 54)
                            .Minutes(1, 2, 3)
                            .Hours(0, 14)
                            .HoursRange(17, 22)
                            .Every(5, CE.Month, 6)
                            .Build();

// result => "0,23,[31-54] 1,2,3 0,14,[17-22] * 6/5 * *"
//Every second, only on Saturday
var cronExpression = new CronExpressionBuilder()
                              .LastDayOfWeek()
                              .Build();

// result => "* * * * * L *"
//Every second, on the fifth Tuesday and Thursday of the month
var cronExpression = new CronExpressionBuilder()
                              .Last(DayOfWeek.Tuesday)
                              .Nth(4, DayOfWeek.Friday)
                              .Build();

// result => "* * * * * 2L,4#5 *"
var cronExpression = new CronExpressionBuilder()
                            .Hours(12,14) 
                            .HoursRange(10,12)
                            .Minutes(30,38)
                            .MinutesRange(40,48)
                            .Seconds(58,59)
                            .SecondsRange(14,19)
                            .Monthes(1,7,8)
                            .MonthRange(2,12)
                            .Years(2030,2031)
                            .DaysOfMonth(7,10)
                            .DaysOfMonthRange(16,31)
                            .LastDaysOfMonth()
                            .NearestWeekdayTo(10) //nearest Weekday to 10th of month
                            .DaysOfWeek(DayOfWeek.Sunday, DayOfWeek.Friday)
                            .LastDayOfWeek()
                            .Last(DayOfWeek.Monday) //last Monday of month
                            .Nth(4, DayOfWeek.Friday) //4th Friday of month
                            .Every(20,CE.Hour)
                            .Every(20,CE.Minute,23)
                            .Every(14,CE.Second,4)
                            .Every(4,CE.Month, 3)
                            .Every(2,CE.DayOfMonth, 13)
                            .Build();

Where can I get it?

PM> Install-Package RM.CronExpression

Or from the .NET CLI as:

dotnet add package RM.CronExpression
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 100 2/11/2025