DEV Community

Hugo Jose
Hugo Jose

Posted on • Edited on

Showcase: NaturalCron — Human-readable recurrence expressions for .NET

I built NaturalCron, a C# library that makes scheduling recurring events as easy to read as:

every 25 minutes on friday between 1:00pm and 3:00pm
Enter fullscreen mode Exit fullscreen mode

Instead of wrestling with cryptic CRON syntax, you can define schedules in a natural-language–style format. It’s especially handy for storing schedules in a database or letting end-users view/edit them

using System;
using NaturalCron;

// Define an advanced expression
string expression = "every 30 minutes in [jan, jun] between 09:00 and 18:00";

// Parse and calculate next occurrence (local time)
NaturalCronExpr schedule = NaturalCronExpr.Parse(expression);
DateTime next = schedule.GetNextOccurrence(DateTime.Now);

Console.WriteLine($"Next occurrence: {next}");


Enter fullscreen mode Exit fullscreen mode

Why?

CRON is powerful but hard to read. RecurlyEx aims to bring flexibility and readability for developers and end-users alike.

GitHub: https://github.com/hugoj0s3/NaturalCron

Top comments (0)