Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 2.04 KB

README.md

File metadata and controls

52 lines (40 loc) · 2.04 KB

aweXpect.Chronology

Nuget Build Quality Gate Status 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));