Hron 1.0.0
dotnet add package Hron --version 1.0.0
NuGet\Install-Package Hron -Version 1.0.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="Hron" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hron" Version="1.0.0" />
<PackageReference Include="Hron" />
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 Hron --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Hron, 1.0.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 Hron@1.0.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=Hron&version=1.0.0
#tool nuget:?package=Hron&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Hron - Human-Readable Cron for .NET
A .NET library for parsing and evaluating human-readable scheduling expressions.
Installation
dotnet add package Hron
Usage
using Hron;
// Parse a schedule expression
var schedule = Schedule.Parse("every weekday at 9:00 in America/New_York");
// Get the next occurrence
var next = schedule.NextFrom(DateTimeOffset.Now);
if (next.HasValue)
{
Console.WriteLine($"Next: {next.Value}");
}
// Get multiple occurrences
var nextFive = schedule.NextNFrom(DateTimeOffset.Now, 5);
foreach (var occurrence in nextFive)
{
Console.WriteLine(occurrence);
}
// Check if a time matches
var isMatch = schedule.Matches(new DateTimeOffset(2026, 2, 10, 9, 0, 0, TimeSpan.FromHours(-5)));
// Convert to cron (if possible)
var cron = schedule.ToCron();
// Get canonical string representation
var canonical = schedule.ToString();
// Access timezone
var timezone = schedule.Timezone; // "America/New_York" or null
Expression Syntax
every day at 09:00
every weekday at 9:00, 17:00
every monday, wednesday, friday at 10:00
every 2 weeks on monday at 09:00
every month on the 1st at 09:00
every month on the last weekday at 17:00
every month on the first monday at 09:00
every year on dec 25 at 00:00
every 30 min from 09:00 to 17:00
on feb 14 at 09:00
Modifiers
every day at 09:00 except dec 25
every day at 09:00 until 2026-12-31
every 3 days at 09:00 starting 2026-01-01
every day at 09:00 during jan, feb, mar
every day at 09:00 in America/New_York
Cron Conversion
// From hron to cron
var schedule = Schedule.Parse("every day at 09:00");
var cron = schedule.ToCron(); // "0 9 * * *"
// From cron to hron
var schedule2 = Schedule.FromCron("0 9 * * 1-5");
Console.WriteLine(schedule2); // "every weekday at 09:00"
Error Handling
try
{
var schedule = Schedule.Parse("invalid expression");
}
catch (HronException ex)
{
Console.WriteLine(ex.Kind); // ErrorKind.Parse
Console.WriteLine(ex.Message); // Error description
Console.WriteLine(ex.Span); // Location in input
Console.WriteLine(ex.DisplayRich()); // Formatted error with underline
}
Validation
if (Schedule.Validate("every day at 09:00"))
{
Console.WriteLine("Valid!");
}
Requirements
- .NET 10.0 or later
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.
-
net10.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.