CronCraft 1.1.0

dotnet add package CronCraft --version 1.1.0
                    
NuGet\Install-Package CronCraft -Version 1.1.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="CronCraft" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CronCraft" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CronCraft" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CronCraft --version 1.1.0
                    
#r "nuget: CronCraft, 1.1.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.
#:package CronCraft@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CronCraft&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CronCraft&version=1.1.0
                    
Install as a Cake Tool

๐Ÿ•’ CronCraft

CronCraft is a lightweight, developer-friendly .NET SDK that converts cron expressions into human-readable strings โ€” with support for localization, formatting, and time zone awareness โ€” no configuration files required.


๐Ÿค” Why CronCraft?

CronCraft is designed for clarity, speed, and minimal setup.

Whether you're building a web app, a CLI tool, a Windows Service, or a background worker โ€” just create a CronSettings object, and you're good to go.

โ No dependency injection required. No appsettings. Just clean, functional cron parsing. โž


โœจ Features

  • ๐Ÿ”„ Converts standard or Quartz cron expressions to plain language
  • ๐ŸŒ Localized day-of-week formatting (short, full, single, or custom)
  • ๐Ÿ•˜ Time zone adjustment (optional)
  • ๐Ÿ”ง Fully configurable via CronSettings object
  • ๐Ÿ’‰ Optional dependency injection registration with AddCronCraft
  • ๐Ÿ“ฆ Lightweight, zero-dependency core logic

๐Ÿ“ฆ Installation

dotnet add package CronCraft

๐Ÿ› ๏ธ Usage Example

using CronCraft.Models;
using CronCraft.Extensions;

string cronExpression = "0 0 * * *"; // Every day at midnight

var settings = new CronSettings
{
    Language = "en",
    DayNameFormat = "short",
    TimeFormat = "HH:mm" // Optional: 24-hour output (default: "hh:mm tt")
};

// Without timezone
string humanReadable = cronExpression.ToHumanReadable(settings);
Console.WriteLine("๐Ÿ” CronCraft Expression Translator");
Console.WriteLine("-----------------------------------");
Console.WriteLine($"๐Ÿงพ Cron Expression:   {cronExpression}");
Console.WriteLine($"๐Ÿ“– Human Readable:    {humanReadable}");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Press Enter to exit...");

// With TimeZone
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("W. Central Africa Standard Time");
humanReadable = cronExpression.ToHumanReadable(settings, timeZone);
Console.WriteLine($"๐Ÿ“– Human Readable (Local TZ): {humanReadable}");

Console.ReadLine();

Dependency Injection

For ASP.NET Core and generic host applications, register CronCraft through IServiceCollection:

using CronCraft.Extensions;

builder.Services.AddCronCraft(settings =>
{
    settings.Language = "en";
    settings.DayNameFormat = "short";
});

Then inject CronCraftService where it is needed:

public class MyScheduler(CronCraftService cronCraft)
{
    public string Describe(string expression) => cronCraft.Convert(expression);
}

Expected Output:

๐Ÿ” CronCraft Expression Translator
-----------------------------------
๐Ÿงพ Cron Expression:   0 0 * * *
๐Ÿ“– Human Readable:    Every day at 12:00 AM
-----------------------------------
๐Ÿ“– Human Readable (Local TZ): Every day at 01:00 AM
Press Enter to exit...

โœ… Validation and Non-Throwing Conversion

ToHumanReadable continues to throw ArgumentException, InvalidCronExpressionException, or timezone exceptions when invalid input is exceptional:

try
{
    string description = cronExpression.ToHumanReadable(settings);
}
catch (InvalidCronExpressionException ex)
{
    Console.WriteLine(ex.ValidationError.Code);
}

Interactive applications can use the non-throwing API instead:

if (cronExpression.TryToHumanReadable(
        settings,
        out var description,
        out var error))
{
    Console.WriteLine(description);
}
else
{
    Console.WriteLine($"{error!.Code}: {error.Message}");
}

bool valid = cronExpression.IsValid(settings);
bool detailed = cronExpression.TryValidate(out var validationError, settings);

Dependency-injection users can call TryConvert, TryValidate, and IsValid on CronCraftService.

Stable error codes are available through CronValidationErrorCodes:

Code Meaning
null_expression The expression reference is null
empty_expression The expression is empty or whitespace
invalid_part_count The expression has an unsupported field count
invalid_field_value A cron field contains an invalid value
invalid_range A range is malformed, out of bounds, or reversed
unsupported_syntax CronCraft does not support the supplied syntax
invalid_time_zone The configured timezone is unavailable
invalid_settings Another formatting or mapping setting is invalid

๐Ÿ”ง Supported Day Name Formats

  • full: e.g. "Sunday"
  • short: e.g. "Sun"
  • single: e.g. "S"
  • custom: fully user-defined via Dictionary<string, string>

๐Ÿ“… Named Weekdays and Months

Weekday and month abbreviations are case-insensitive and work in individual, list, and range expressions:

"0 9 * JAN MON".ToHumanReadable(settings);
// Every Mon in January at 09:00 AM

"0 9 * * MON-FRI".ToHumanReadable(settings);
// Every Mon through Fri at 09:00 AM

"0 0 1 JAN,JUL *".ToHumanReadable(settings);
// Every year on January 1st and July 1st at 12:00 AM

Supported weekday names are SUN through SAT; supported month names are JAN through DEC.


โšก Cron Aliases

Common Unix cron aliases can be used instead of five-part expressions:

"@hourly".ToHumanReadable(settings);  // Every hour
"@daily".ToHumanReadable(settings);   // Every day at 12:00 AM
"@weekly".ToHumanReadable(settings);  // Every Sun at 12:00 AM
"@monthly".ToHumanReadable(settings); // Every month on the 1st at 12:00 AM
"@yearly".ToHumanReadable(settings);  // Every year on January 1st at 12:00 AM
"@reboot".ToHumanReadable(settings);  // At system reboot

Aliases are case-insensitive and produce localized descriptions using the selected CronSettings.Language.


โฑ๏ธ Quartz Seconds and Years

Quartz expressions may contain six fields (including seconds) or seven fields (including an optional year):

"*/10 * * * * ?".ToHumanReadable(settings);
// Every 10 seconds

"30 15 10 * * ?".ToHumanReadable(settings);
// Every day at 10:15:30 AM

"0 0 12 * * ? 2027-2029".ToHumanReadable(settings);
// Every day at 12:00 PM in 2027 through 2029

Seconds support fixed values, wildcards, steps, lists, and ranges from 0 to 59. A non-zero fixed second is added to the rendered time even when TimeFormat omits ss; formats that already contain seconds are preserved.

Years support values, steps, lists, and ranges from 1970 to 2099. A * year remains unrestricted and is omitted from the description. Five-field Unix cron expressions keep their existing behavior.


๐ŸŒ Languages Supported

  • English (en)
  • Spanish (es)
  • French (fr)
  • German (de)
  • Portuguese (pt)
  • Italian (it)
  • Dutch (nl)
  • Simplified Chinese (zh)
  • Japanese (ja)
  • Easily extendable via custom mappings

Localized descriptions use language-specific ordinals, conjunctions, ranges, and singular forms:

var french = new CronSettings { Language = "fr", DayNameFormat = "short" };

string description = "0 9 * * 1,3,5".ToHumanReadable(french);
// Chaque lun, mer et ven ร  09:00 AM

๐Ÿง‘โ€๐Ÿ’ป Author

Esanju Babatunde
GitHub ยท LinkedIn


๐Ÿค Contributing

Contributions are welcome! If you'd like to:

  • Fix a bug
  • Improve performance
  • Add support for a new language
  • Refactor or improve documentation

Feel free to open a Pull Request or start a Discussion.

Before contributing:

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m 'Add your message')
  4. Push to the branch (git push origin feature/your-feature)
  5. Open a pull request ๐Ÿš€

If you're not sure where to start, check the issues.

Let's make cron expressions human again! โค๏ธ


๐Ÿ“„ License

This project is licensed under the MIT License.
See the LICENSE file for details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 109 11/13/2026
1.0.6 191 6/23/2026
1.0.5 139 6/18/2026
1.0.4 136 6/15/2026
1.0.3 135 6/15/2026
1.0.2 440 6/12/2025
1.0.0 401 6/12/2025