https://github.com/jirikostiha/atin
Utilities for parsing and formatting time spans to and from alphanumeric time interval notation.
https://github.com/jirikostiha/atin
duration-parsing notation parser time-conversion time-format time-interval time-parsing
Last synced: 3 months ago
JSON representation
Utilities for parsing and formatting time spans to and from alphanumeric time interval notation.
- Host: GitHub
- URL: https://github.com/jirikostiha/atin
- Owner: jirikostiha
- License: mit
- Created: 2024-09-20T14:15:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-17T18:42:53.000Z (over 1 year ago)
- Last Synced: 2024-11-20T01:51:36.585Z (over 1 year ago)
- Topics: duration-parsing, notation, parser, time-conversion, time-format, time-interval, time-parsing
- Language: C#
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Alphanumeric Time Interval Notation (ATIN)


[](https://github.com/jirikostiha/atin/actions/workflows/build.yml)
[](https://github.com/jirikostiha/atin/actions/workflows/lint-code.yml)
## Overview
This project provides utilities for parsing and formatting alphanumeric time intervals like D1, H3, M5, W2H1S10.
## Features
- **Parse Atin format to TimeSpan**: The `AtinParser.Parse` method converts a string representation of a time span (weeks, days, hours, minutes, seconds) into a `TimeSpan` object.
- **Format TimeSpan to Atin**: The `ToAtin` extension method converts a `TimeSpan` object into a string using the "Atin" format.
## Example Usage
### Parsing a TimeSpan from a string
The following example shows how to use the `AtinParser.Parse` method to convert a formatted string into a `TimeSpan` object.
```csharp
Console.WriteLine(AtinParser.Parse("H2")); // Output: 02:00:00
Console.WriteLine(AtinParser.Parse("W1D2H3M4S5")); // Output: 9.03:04:05
```
### Formatting a TimeSpan to Atin format
Use the `ToAtin` extension method to convert a `TimeSpan` object into an "Atin"-formatted string.
```csharp
Console.WriteLine(TimeSpan.FromHours(2).ToAtin()); // Output: H2
Console.WriteLine(new TimeSpan(9, 3, 4, 5).ToAtin()); // Output: W1D2H3M4S5
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.