STYME 0.4.0

dotnet add package STYME --version 0.4.0
                    
NuGet\Install-Package STYME -Version 0.4.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="STYME" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="STYME" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="STYME" />
                    
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 STYME --version 0.4.0
                    
#r "nuget: STYME, 0.4.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 STYME@0.4.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=STYME&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=STYME&version=0.4.0
                    
Install as a Cake Tool

Icon

NuGet Version NuGet Downloads

STYME is a lightweight, zero-dependency C# library for parsing simple natural-language date/time expressions and applying them to a base date/time.

Usage Examples

Basic

using STYME;

// By default NaturalDateTime uses the current system time as the base
var parser = new NaturalDateTime();
var result = parser.Parse("add 2 days");
Console.WriteLine(result);

Output (example):

2025-10-04T14:23:00

You can parse expressions relative to a specific DateTime using NaturalDateTime.From.

using STYME;

var baseTime = new DateTime(2020, 1, 1, 0, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("add 1 month");
Console.WriteLine(result);

Output:

2020-02-01T00:00:00

Add

You can add time using the add keyword.

using STYME;

var baseTime = new DateTime(2020, 3, 1, 12, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("add 1 year");
Console.WriteLine(result);

Output:

2021-03-01T00:00:00

Deduct / Subtract

You can subtract time using the deduct (or subtract) keyword.

using STYME;

var baseTime = new DateTime(2020, 3, 1, 12, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("deduct 1 month");
Console.WriteLine(result);

Output:

2020-02-01T12:00:00

Chaining operations

You can chain multiple operations using and.

using STYME;

var baseTime = new DateTime(2020, 1, 1, 0, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("add 3 days and deduct 5 hours");
Console.WriteLine(result);

Output:

2020-01-03T19:00:00

"next" references

Use next to jump to the upcoming occurrence of a day of the week or a month. The time of day is preserved.

using STYME;

var baseTime = new DateTime(2025, 1, 1, 8, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("next monday");
Console.WriteLine(result);

Output:

2025-01-06T08:00:00

This operator can also be chained with the and operator.

using STYME;

var baseTime = new DateTime(2025, 1, 1, 8, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("next friday and add 2 hours");
Console.WriteLine(result);

Output:

2025-01-03T10:00:00

"end of" references

Use end to move to the end of the current week, month, or year. Fillers such as of and the are optional.

using STYME;

var baseTime = new DateTime(2025, 6, 15, 20, 45, 0);
var parser = NaturalDateTime.From(baseTime);
var result = parser.Parse("end of the month");
Console.WriteLine(result);

Output:

2025-06-30T20:45:00

Recurring schedules

You can generate a lazy sequence of future dates using every. The sequence is infinite, so add your own break condition.

using STYME;

var baseTime = new DateTime(2025, 1, 1, 0, 0, 0);
var parser = NaturalDateTime.From(baseTime);
var schedule = parser.Enumerate("every 2 weeks");

foreach (var occurrence in schedule)
{
    Console.WriteLine(occurrence);
    // Break when you reach the point you care about.
    if (occurrence >= new DateTime(2025, 2, 12))
    {
        break;
    }
}

Output:

2025-01-01T00:00:00
2025-01-15T00:00:00
2025-01-29T00:00:00
2025-02-12T00:00:00

Supported units with add and deduct

The add and deduct expressions support the following units (singular and plural forms):

  • second, seconds
  • minute, minutes
  • hour, hours
  • day, days
  • week, weeks
  • month, months
  • year, years
  • decade, decades
  • century, centuries
  • millennium, millennia

Example:

using STYME;

var parser = NaturalDateTime.From(new DateTime(2000, 1, 1));
Console.WriteLine(parser.Parse("add 2 decades")); // 2020-01-01
Console.WriteLine(parser.Parse("deduct 1 century")); // 1900-01-01

Todo

  • Add month support (set DateTime to specific month)
  • Add day support (i.e. "next friday")
  • [] Add complex time support (i.e. "quarter past five")
  • [] Add multiple complex operations (i.e. "add one year then next friday")

Support

  • .NET 8.0 and later

License

STYME is licensed under the MIT License.

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 is compatible.  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 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.
  • net8.0

    • No dependencies.
  • net9.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
0.4.0 226 11/23/2025
0.3.0 360 11/21/2025
0.2.1 219 10/7/2025
0.1.0 176 10/3/2025

- Added support for `next` expressions targeting days of the week and months.
           - Added support for `end of` expressions targeting weeks, months, and years.