Represents a duration of time with decomposed fields.
Supports construction from milliseconds, maps, or ISO 8601 duration strings.
Summary
Functions
Adds two durations field-wise.
Returns total duration in days.
Returns total duration in hours.
Returns total duration in milliseconds.
Returns total duration in minutes.
Returns total duration in months.
Returns total duration in seconds.
Returns total duration in weeks.
Returns total duration in years.
Returns a human-readable string for the duration.
Create a Duration from milliseconds (integer), a map of fields, or an ISO 8601 duration string.
Subtracts two durations field-wise.
Returns the duration as an ISO 8601 duration string.
Types
Functions
Adds two durations field-wise.
Returns total duration in days.
Returns total duration in hours.
Returns total duration in milliseconds.
Returns total duration in minutes.
Returns total duration in months.
Returns total duration in seconds.
Returns total duration in weeks.
Returns total duration in years.
Returns a human-readable string for the duration.
When with_suffix is true, prefixes positive durations with "in ".
Create a Duration from milliseconds (integer), a map of fields, or an ISO 8601 duration string.
From milliseconds: decomposes into hours/minutes/seconds/milliseconds only (no calendar days). From map: direct field assignment with defaults of 0. From ISO string: parses "P[nY][nM][nD][T[nH][nM][nS]]".
Subtracts two durations field-wise.
Returns the duration as an ISO 8601 duration string.
Zero duration returns "P0D".