Skip to main content
net8.0.NETStandard2.0

Extension methods for creating chronology objects like `TimeSpan` or `DateTime` that read more natural.

Published
Feb 16, 2025
1y ago
Total Downloads
42.9K
42,895

Install

dotnet add package aweXpect.Chronology --version 1.0.0
ProductVersions
.NET
net8.0
.NET Standard
netstandard2.0

README

aweXpect.Chronology

Changelog Nuget Coverage Mutation testing badge

Extension methods for creating chronology objects like TimeSpan or DateTime that read more natural.

TimeSpan

Add the following extension methods on int and double that allow creating a TimeSpan:

  • .Milliseconds()
  • .Seconds()
  • .Minutes()
  • .Hours()
  • .Days()
// ↓ Using traditional creation of TimeSpan
TimeSpan timeout = TimeSpan.FromSeconds(10);
TimeSpan timeout = 10.Seconds();
// ↑ Using the extension methods from this library

It is also possible to combine multiple extension methods:

TimeSpan timeout = 1.Minutes(30.Seconds());

DateTime

Add extension methods on int for each month that allow creating a DateTime:

// ↓ Using traditional creation of DateTime
DateTime time = new DateTime(2024, 12, 24);
DateTime time = 24.December(2024);
// ↑ Using the extension methods from this library

It is also possible to specify a time:

DateTime time = 24.December(2024).At(18, 30);

It is also possible combine this with the TimeSpan extensions:

DateTime time = 3.Hours().Before(25.December(2024));

Changes from Previous Version

No structural changes between v0.6.0 and v1.0.0.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.