TemporalDuration class final
A duration spanning both calendar units (years, months, weeks, days) and time units (hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
Unlike Dart's Duration, calendar units are not converted to fixed time units — a month is always "one month" regardless of how many days it contains. This matches the TC39 Temporal specification.
Constructors
- TemporalDuration({int years = 0, int months = 0, int weeks = 0, int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0, num microseconds = 0, num nanoseconds = 0})
-
Constructs a duration from individual components.
factory
- TemporalDuration.from(String iso)
-
Parses an ISO 8601 duration string such as
'P1Y2M3DT4H5M6S'.factory
Properties
- days → int
-
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- hours → int
-
no setter
- isZero → bool
-
no setter
- microseconds → double
-
no setter
- milliseconds → int
-
no setter
- minutes → int
-
no setter
- months → int
-
no setter
- nanoseconds → double
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seconds → int
-
no setter
- weeks → int
-
no setter
- years → int
-
no setter
Methods
-
abs(
) → TemporalDuration - Returns this duration with all components made non-negative.
-
add(
TemporalDuration other) → TemporalDuration -
Returns the sum of this duration and
other. -
negated(
) → TemporalDuration - Returns this duration with all signs flipped.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
subtract(
TemporalDuration other) → TemporalDuration -
Returns the difference of this duration and
other. -
toString(
) → String -
Returns the ISO 8601 duration string, e.g.
'P1Y2M3DT4H'.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override