A .NET utility library providing extension methods for common types to simplify development.
Converts a total number of seconds into minutes and remaining seconds.
using Nextensions;
int totalSeconds = 1000;
var (minutes, seconds) = totalSeconds.ToMinutesAndSeconds();
// minutes = 16, seconds = 40Formats a TimeSpan into a human-readable string including days, hours, minutes, and seconds.
using Nextensions;
TimeSpan ts = TimeSpan.FromSeconds(1000);
string readable = ts.ToReadableDuration();
// "16m 40s"Computes a human-readable duration between two DateTime instances including years, months, days, hours, minutes, and seconds.
using Nextensions;
DateTime from = new DateTime(2023, 1, 1);
DateTime to = DateTime.Now;
string result = from.ToReadableDuration(to);
// e.g. "2y 9mo 12d 3h 15m 40s"Add the library to your project:
dotnet add reference path/to/Nextensions.csprojOr include it as a NuGet package once published.
- Simplify duration formatting and calculations
- Provide intuitive, human-readable outputs
- Integrate seamlessly as extensions in .NET projects
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is open source.