https://github.com/frobware/comptime
Parse composite time durations
https://github.com/frobware/comptime
Last synced: about 1 year ago
JSON representation
Parse composite time durations
- Host: GitHub
- URL: https://github.com/frobware/comptime
- Owner: frobware
- License: mit
- Created: 2024-04-04T10:08:13.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-18T22:02:07.000Z (over 1 year ago)
- Last Synced: 2025-02-24T07:38:23.340Z (about 1 year ago)
- Language: Go
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# comptime: Parse composite time durations, including support for days
The `comptime` package (composite time) extends the capabilities of the standard library's `time.ParseDuration` function. It introduces support for 'days', amongst other features.
## Key Features
- Supports 'days' as an additional time unit (denoted by 'd').
- Flexible parsing modes:
- Multi-unit mode for parsing composite strings (e.g., "24d20h31m23s647ms").
- Single-unit mode to ensure only one unit type is present.
- Custom range checking via a callback function, allowing for user-defined limits and early termination.
- Ability to specify a default unit for values without an explicit unit (e.g., interpreting "500" as 500ms).
## Performance
`comptime` is designed for efficiency. For detailed performance comparisons with the standard library, see [BENCHMARKS.md](./BENCHMARKS.md).
## Development
```sh
$ make
$ make benchmark
$ make benchmark-profile
```
For more detailed information and usage examples, please refer to the [package documentation](https://pkg.go.dev/github.com/frobware/comptime).