add ISODuration type for ISO8061 duration compatibility

This commit is contained in:
2025-12-11 20:25:29 -08:00
parent 6ecb12c98c
commit a84cfde045
4 changed files with 140 additions and 0 deletions
+18
View File
@@ -1,3 +1,21 @@
# clocktime
clocktime provides a type that holds a calendar-independent time of day value in 24-hour format.
clocktime provides basic types that extend Go's built-in time.Time to provide time-of-day and duration support.
## `clocktime.ClockTime
Holds calendar-independent time-of-day in 24-hour format.
- Converts to and from `HH:MM:SS` format (subset of ISO8061)
- Marshals to `[]byte` containing string `HH:MM:SS` for SQL
- Marshals to `string` in format `HH:MM:SS` for JSON & gqlgen
## `clocktime.Duration`
Wraps time.Duration with prioritized ISO8061 support and opinionated marshalling.
- Converts to and from ISO8061 format (utilises [sosodev/duration](https://github.com/sosodev/duration))
- Marshals to `uint64` with nanosecond precision. Largest representatable duration is about 290 years, limited by underlying time.Duration type.
- Marshals to `string` in ISO8061 format for JSON & gqlgen