https://github.com/mostafatech/fluentcronexpression
A utility to build standard cron expressions fluently based on crontab
https://github.com/mostafatech/fluentcronexpression
cron cronexpression crontab hangfire
Last synced: 3 months ago
JSON representation
A utility to build standard cron expressions fluently based on crontab
- Host: GitHub
- URL: https://github.com/mostafatech/fluentcronexpression
- Owner: MostafaTech
- License: mit
- Created: 2021-02-14T17:39:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-18T18:58:24.000Z (about 4 years ago)
- Last Synced: 2025-02-08T21:43:13.289Z (3 months ago)
- Topics: cron, cronexpression, crontab, hangfire
- Language: C#
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Fluent Cron Expression
A utility to build standard cron expressions fluently based on crontab## Install
```
PM> Install-Package FluentCronExpression
```## Usage
You can browse tests for complete usage.```csharp
// initialize cron expression builder
using FluentCronExpression;
var cron = new StandardCronExpressionBuilder();// every one minute => */1 * * * *
var exp = cron.WithMinutesEvery(1).Build();// 1st day of every month => 0 0 1 * *
var exp = cron.WithDayOfMonth(1).WithMinute(0).WithHour(0).Build();
// or use extension methods
var exp = cron.SetEveryMonth().Build();// every monday => 0 0 * * SUN
var exp = cron.WithWeekDay(2).WithMinute(0).WithHour(0).Build();
// or use extension methods
var exp = cron.SetEveryDayOfWeek(DayOfWeek.Monday).Build();// between 06:00 to 06:59 every 5 minutes daily => 0-59/5 6 * * *
var exp = cron.WithMinutesBetween(0, 59).WithHoursBetween(6, 6).WithMinutesEvery(5).Build();
// or use extension methods
var exp = cron.SetFromHourMinuteToHourMinuteString("06:00", "06:59").WithMinutesEvery(5).Build();
```