TemporalZ

Duration

The Temporal.Duration object represents a difference between two time points, which can be used in date/time arithmetic. It is fundamentally represented as a combination of years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds values.

See: Temporal.Duration

Fields

#
_inner:*abi.c.Duration
*abi.c.Duration

Types

#
RoundingOptions

Options for rounding a Duration.

PartialDuration

Partial duration specification for creating Duration objects.

RelativeTo

Relative-to context for duration operations, used for balancing and calendar-aware math.

TotalOptions

Options for Duration.total() providing unit and relative-to context.

CompareOptions

Options for Duration.compare() providing relative-to context.

Functions

#
init

Construct a Duration from years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds.

from

The Temporal.Duration.from() static method creates a new Temporal.Duration object from one of the following:

years

Returns the number of years in the duration.

months

Returns the number of months in the duration.

weeks

Returns the number of weeks in the duration.

days

Returns the number of days in the duration.

hours

Returns the number of hours in the duration.

minutes

Returns the number of minutes in the duration.

seconds

Returns the number of seconds in the duration.

milliseconds

Returns the number of milliseconds in the duration.

microseconds

Returns the number of microseconds in the duration.

nanoseconds

Returns the number of nanoseconds in the duration.

sign

Returns the sign of the duration: positive (1), zero (0), or negative (-1).

blank

Returns true if the duration is zero (all fields are zero), false otherwise.

abs

Returns a new Duration with the absolute value (all components positive).

negated

Returns a new Duration with all components negated (sign reversed).

add

Returns a new Duration with the sum of this duration and another (balanced as needed).

subtract

Returns a new Duration with the difference between this duration and another (balanced as needed).

round

Returns a new Duration rounded to the given smallest/largest unit and/or balanced.

compare

Compares two durations, returning -1, 0, or 1 if this duration is shorter, equal, or longer than the other.

total

Returns the total value of the duration in the specified unit.

toString

Returns a string representing this duration in the ISO 8601 format.

toJSON

Returns a string representing this duration in the ISO 8601 format (same as toString). Intended for JSON serialization.

toLocaleString

Returns a string with a language-sensitive representation of this duration.

deinit

Deinitialize the Duration, freeing underlying resources.

Aliases

#
ToStringOptions

Options for controlling stringification of a Duration.

ToStringRoundingOptions

Options for controlling stringification of a Duration (alias).

Unit

Units supported by Temporal.Duration (years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).

RoundingMode

Rounding modes for Duration operations.

Sign

The sign of a Duration: positive, zero, or negative.