This project provides utilities for parsing and formatting alphanumeric time intervals like D1, H3, M5, W2H1S10.
- Parse Atin format to TimeSpan: The
AtinParser.Parsemethod converts a string representation of a time span (weeks, days, hours, minutes, seconds) into aTimeSpanobject. - Format TimeSpan to Atin: The
ToAtinextension method converts aTimeSpanobject into a string using the "Atin" format.
The following example shows how to use the AtinParser.Parse method to convert a formatted string into a TimeSpan object.
Console.WriteLine(AtinParser.Parse("H2")); // Output: 02:00:00
Console.WriteLine(AtinParser.Parse("W1D2H3M4S5")); // Output: 9.03:04:05Use the ToAtin extension method to convert a TimeSpan object into an "Atin"-formatted string.
Console.WriteLine(TimeSpan.FromHours(2).ToAtin()); // Output: H2
Console.WriteLine(new TimeSpan(9, 3, 4, 5).ToAtin()); // Output: W1D2H3M4S5This project is licensed under the MIT License - see the LICENSE file for details.