Lightweight .NET library to parse human-friendly time span expressions like '2h', '15m', '1d 3h 20m'.
$ dotnet add package SmartTimeSpanParserA developer-friendly .NET library for parsing natural time duration expressions like
"2h 30m"or"1.5 days"into usableTimeSpanobjects.
2h, 1.5 hours30 minutes, 45m, 90s1h 15m, 2 days 3hTimeSpanInstall from NuGet (coming soon):
dotnet add package SmartTimeSpanParser
var duration = SmartTimeSpan.Parse("2h 30m");
Console.WriteLine(duration); // 02:30:00
if (SmartTimeSpan.TryParse("45 minutes", out var parsed))
{
Console.WriteLine(parsed); // 00:45:00
}
| Input | Description |
|---|---|
2h | 2 hours |
1.5 days | 36 hours |
30m or 30 minutes | 30 minutes |
90s | 90 seconds |
1h 15m | 1 hour and 15 minutes |
2d 3h | 2 days and 3 hours |
More formats and units coming soon!
ToHumanString() method for output like "2 hours, 15 minutes"fr, de, es)See CHANGELOG.md
dotnet test
Pull requests welcome! Please see CONTRIBUTING.md for details.
MIT — see LICENSE
⭐ If you find this useful, give it a star!