FluentCron 1.0.0
dotnet add package FluentCron --version 1.0.0
NuGet\Install-Package FluentCron -Version 1.0.0
<PackageReference Include="FluentCron" Version="1.0.0" />
<PackageVersion Include="FluentCron" Version="1.0.0" />
<PackageReference Include="FluentCron" />
paket add FluentCron --version 1.0.0
#r "nuget: FluentCron, 1.0.0"
#:package FluentCron@1.0.0
#addin nuget:?package=FluentCron&version=1.0.0
#tool nuget:?package=FluentCron&version=1.0.0
FluentCron
Stop writing cron expressions by hand. Build them with a fluent API instead.
// Instead of this:
var cron = "0 9-17 * * 1-5";
// Write this:
var cron = new CronBuilder()
.AtMinute(0)
.HourRange(9, 17)
.DayOfWeekRange(DayOfWeek.Monday, DayOfWeek.Friday)
.Build();
Installation
dotnet add package FluentCron
Why?
- No more string errors - Type-safe cron expression building
- Unix & Quartz formats - Works with everything (crontab, Hangfire, Quartz.NET)
- Readable -
Cron.Daily()beats"0 0 * * *"every time - Tested - 370 tests including integration tests with Quartz.NET and Hangfire
Quick Examples
using FluentCron;
// Every 5 minutes
new CronBuilder().EveryNMinutes(5).Build();
// → */5 * * * *
// Weekdays at 9 AM
Cron.Weekdays(9, 0);
// → 0 9 * * 1,2,3,4,5
// Last Friday of the month at 6 PM (Quartz)
new CronBuilder(CronFormat.Quartz)
.AtSecond(0)
.AtMinute(0)
.AtHour(18)
.OnLastWeekdayOfMonth(DayOfWeek.Friday)
.Build();
// → 0 0 18 ? * 6L *
Common Patterns
Daily Tasks
Cron.Daily(); // Midnight
Cron.DailyAt(14, 30); // 2:30 PM
Weekly Tasks
Cron.Weekly(); // Sunday at midnight
Cron.WeeklyOn(DayOfWeek.Friday, 17, 0); // Friday at 5 PM
Business Hours
new CronBuilder()
.EveryNMinutes(15)
.HourRange(9, 17)
.OnDayOfWeek(DayOfWeek.Monday, DayOfWeek.Tuesday,
DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday)
.Build();
// → */15 9-17 * * 1,2,3,4,5
Advanced Patterns
// Every 2 hours during business hours
new CronBuilder()
.AtMinute(0)
.HourRangeWithStep(9, 17, 2)
.Build();
// → 0 9-17/2 * * *
// Second Tuesday of the month (Quartz)
new CronBuilder(CronFormat.Quartz)
.AtSecond(0)
.AtMinute(30)
.AtHour(14)
.OnNthWeekdayOfMonth(DayOfWeek.Tuesday, 2)
.Build();
// → 0 30 14 ? * 3#2 *
Framework Integration
Hangfire
var cronExpression = new CronBuilder()
.EveryNMinutes(5)
.Build();
RecurringJob.AddOrUpdate(() => MyJob(), cronExpression);
Quartz.NET
var cronExpression = new CronBuilder(CronFormat.Quartz)
.AtSecond(0)
.EveryNMinutes(5)
.Build();
var trigger = TriggerBuilder.Create()
.WithCronSchedule(cronExpression)
.Build();
NCrontab / System Cron
var cronExpression = new CronBuilder()
.EveryNMinutes(5)
.Build();
var schedule = CrontabSchedule.Parse(cronExpression);
API Overview
Time Fields
AtSecond(0, 30)- Specific seconds (Quartz only)AtMinute(0, 15, 30, 45)- Specific minutesAtHour(9, 17)- Specific hoursOnDayOfMonth(1, 15)- Specific daysInMonth(1, 6, 12)- Specific monthsOnDayOfWeek(DayOfWeek.Monday)- Specific weekdays
Intervals
EveryNSeconds(10)- Every 10 seconds (Quartz only)EveryNMinutes(5)- Every 5 minutesEveryNHours(2)- Every 2 hoursEveryNDays(3)- Every 3 days
Ranges
MinuteRange(10, 40)- Minutes 10-40HourRange(9, 17)- Hours 9-17DayRange(1, 15)- Days 1-15MonthRange(6, 8)- Months 6-8 (June-August)DayOfWeekRange(DayOfWeek.Monday, DayOfWeek.Friday)- Monday-Friday
Ranges with Steps
MinuteRangeWithStep(10, 40, 5)- Every 5 minutes between 10-40HourRangeWithStep(9, 17, 2)- Every 2 hours between 9 AM-5 PM
Quartz Special Characters
OnLastDayOfMonth()- Last day of month (L)OnNearestWeekday(15)- Nearest weekday to the 15th (15W)OnLastWeekdayOfMonth(DayOfWeek.Friday)- Last Friday (6L)OnNthWeekdayOfMonth(DayOfWeek.Tuesday, 2)- 2nd Tuesday (3#2)OnLastWeekday()- Last weekday of month (LW)
Formats
Unix (Default)
5 fields: minute hour day month weekday
new CronBuilder().EveryNMinutes(5).Build();
// → */5 * * * *
Quartz
7 fields: second minute hour day month weekday year
new CronBuilder(CronFormat.Quartz).EveryNMinutes(5).Build();
// → 0 */5 * * * ? *
Error Handling
FluentCron validates everything at build time:
// This will throw ArgumentOutOfRangeException
new CronBuilder().AtMinute(99).Build(); // Minutes must be 0-59
// This will throw InvalidOperationException
new CronBuilder(CronFormat.Unix).AtSecond(0).Build(); // Seconds only in Quartz
// This will throw ArgumentException
new CronBuilder().OnDayOfWeek().Build(); // Must specify at least one day
Testing
370 comprehensive tests including:
- Unit tests for all features
- Integration tests with Quartz.NET
- Integration tests with Hangfire
- Edge case and validation tests
Run tests:
dotnet test
License
MIT - see LICENSE file
Contributing
Issues and PRs welcome! This is a straightforward library - if you need a feature, open an issue first to discuss.
Built with ❤️ by Yigitalp Kilavuz
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.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 | 284 | 10/2/2025 |
Initial release of FluentCron v1.0.0
Features:
- Fluent API for building cron expressions with intuitive method chaining
- Dual format support: Unix (5-field) and Quartz (6-7 field) cron expressions
- 36+ builder methods including ranges, intervals, and special characters
- Predefined patterns: Daily, Weekly, Monthly, Yearly, Weekdays, Weekends
- Quartz-specific features: last day of month (L), nearest weekday (W), nth occurrence (#)
- Type-safe API with comprehensive input validation
- Full XML documentation for IntelliSense support
Quality:
- 393 tests with 100% pass rate
- 99.57% code coverage
- Integration tests with Quartz.NET and Hangfire
- Performance benchmarks included
- .NET 8.0 LTS target framework
For documentation and examples, visit: https://github.com/yigitalpkilavuz/FluentCron