Duration
A length of time, exact to the millisecond, written PT1H30M.
Time and calendar; ordered; since Jadpo 0.1.0.
Make one
text.parse(raw, as: Duration) reads one from its text; text that isn't one at all fails malformed, such as 5 minutes, P or PT.
This operation gives one: temporal.between.
Text, JSON and storage
text.from writes its canonical text, the one form text.parse reads back. JSON sends its canonical text as a string.
| Text | JSON |
|---|---|
PT5M |
"PT5M" |
PT1H30M |
"PT1H30M" |
PT26H |
"PT26H" |
It is stored in one column named for the field, of type bigint. PT1H30M is stored as 5400000.
Shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
PT5M |
5 minutes |
PT1H30M |
1 hour, 30 minutes |
PT26H |
1 day, 2 hours |
Operations
temporal.between(start: Instant, end: Instant) -> Duration: How long fromstarttoend:end - start.
Like every standard type, it also has the contract's own operations: text.parse, text.from, text.format, json.read, json.write and ==. It is ordered, so < and sorting take it. Every standard type meets one contract says how they work.
Markdown for agents: /docs/types/type-duration.md.Built from Jadpo main at e00e61f.