Expand description
Short duration parsing for CLI flags like --admin-expires 7d, plus
user-facing display helpers.
Internally we always store and transmit times as UTC unix-epoch seconds. Anything shown to the operator is converted to their local timezone for readability.
Duration parsing accepts N[s|m|h|d|w] — seconds, minutes, hours,
days, weeks — or a plain integer which is interpreted as seconds.
Whitespace is trimmed.
Functions§
- duration_
to_ expires_ at - Parse a duration and return the absolute unix-epoch expiry time
(
now + duration). - format_
local_ datetime - Format a
DateTime<Utc>(the protocol-level wire format) as a readable local-timezone string with an ISO-style offset. - format_
local_ time - Format a unix-epoch seconds value as a readable local-timezone string with an ISO-style offset, suitable for operator-facing output.
- format_
remaining - Format a relative-time string showing how long until
unix_secsfromnow_unix(). Handles both future (in 1h 0m) and past (expired 5m ago) cases. Picks the largest sensible unit pair and rounds toward the nearest integer in each. - humanize_
duration - Format a duration in seconds as a compact two-part human string: “1h 30m”, “5d 12h”, “45s”, “0s”. Picks the largest unit that fits and adds one smaller unit when it helps readability.
- now_
unix - Current unix-epoch seconds (UTC, monotonic with the system wall clock).
- parse_
duration_ secs - Parse a duration string into seconds.