end a1284075aa fix: strict ClockTime parsing and ISODuration SQL
Validate constructors, strict HH:MM:SS parse, UTC ClockTimeFromTime,
ISODuration Value/Scan, Compare and TextMarshaler, codec.go split.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 18:01:08 -07:00
2026-01-27 15:09:06 -08:00

clocktime

Time-of-day and ISO 8601 duration types for APIs, GraphQL, and SQL.

Install

go get gitea.auvem.com/go-toolkit/clocktime

ClockTime

ct, err := clocktime.ParseClockTime("09:30:00")
t := ct.Time() // 1970-01-01 UTC anchor
  • Strict HH:MM:SS parsing via [ParseClockTime]
  • SQL TIME columns: stored as []byte / string; scanned from time.Time, []byte, or string
  • Optional fields: use *ClockTime; IsZero() is true only for nil pointers
  • Midnight 00:00:00 is valid; use IsMidnight() to detect it

ISODuration

d, err := clocktime.ParseISODuration("PT1H30M")
ns := d.Duration()
  • JSON/GQL: ISO 8601 strings
  • SQL: int64 nanoseconds (strings accepted on scan)
  • Calendar durations (P1M, P1Y) convert to approximate nanoseconds and may not round-trip

gqlgen

Both types implement MarshalGQL / UnmarshalGQL.

S
Description
clocktime provides a calendar independent time of day object in 24-hour format.
Readme BSD-3-Clause 47 KiB
Languages
Go 100%