Skip Holidays in .NET Scheduled Jobs with NaturalCron Custom Keywords
With NaturalCron 1.1, you can finally teach your .NET jobs what a holiday is. You just add your own words to the schedule, like every day at 09:00 except holiday , and then define what counts as a holiday in C#. It's like giving your scheduler a tiny bit of common sense. How I got to this idea A schedule like “every weekday at 9, but not on holidays” is easy to say and hard to configure. Cron has…
NaturalCron 1.1 allows you to include holidays in .NET scheduled jobs by using custom keywords. Instead of checking the date inside the job, you simply add keywords like "holiday" to your schedule. This lets the scheduler know which dates to exclude without having to write complex date-time logic. You can define a keyword once during application startup using a function that checks if a given date matches the rule (e.g., whether it's a holiday).
This keyword can then be used in your schedule expressions just like built-in values. For example, "every day except holiday" will automatically skip holidays, weekends, and any other dates you define as holidays. This approach simplifies scheduling and makes your code more readable.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.