DurationUtils extension

Extensions on Duration for real-world utility operations.

on

Properties

ago → DateTime

Available on Duration, provided by the DurationUtils extension

Returns a DateTime that is this duration before now.
no setter
formatted → String

Available on Duration, provided by the DurationUtils extension

Returns a human-readable string, e.g. "1h 23m 45s", "45s", "2d 3h".
no setter
fromNow → DateTime

Available on Duration, provided by the DurationUtils extension

Returns a DateTime that is this duration after now.
no setter
inWeeks → int

Available on Duration, provided by the DurationUtils extension

Returns the number of whole weeks in this duration.
no setter
isNegative → bool

Available on Duration, provided by the DurationUtils extension

Returns true if this duration is negative.
no setter
isZero → bool

Available on Duration, provided by the DurationUtils extension

Returns true if this duration is zero.
no setter

Methods

dividedBy(double factor) → Duration

Available on Duration, provided by the DurationUtils extension

Divides this duration by factor and returns a new Duration.
multipliedBy(double factor) → Duration

Available on Duration, provided by the DurationUtils extension

Multiplies this duration by factor and returns a new Duration.
percentageOf(Duration total) → double

Available on Duration, provided by the DurationUtils extension

Returns this duration as a percentage (0.0–1.0+) of total.
toCountdown() → String

Available on Duration, provided by the DurationUtils extension

Returns a human-readable countdown string, e.g. "2d 3h 45m 10s". Omits zero-value units except seconds.
toHhMmSs() → String

Available on Duration, provided by the DurationUtils extension

Returns a zero-padded HH:MM:SS string (e.g. "01:23:45").
toMmSs() → String

Available on Duration, provided by the DurationUtils extension

Returns a zero-padded MM:SS string (e.g. "23:45").