Methods

abs

static

abs(duration) returns rules.Duration

Absolute value of a duration.

Parameter

duration

rules.Duration

Duration value.

Value must not be null.

Returns

non-null rules.Duration the absolute duration value of the input.

Example

duration.abs(duration.value(-10, 's')) == duration.value(10, 's')

time

static

time(hours, mins, secs, nanos) returns rules.Duration

Create a duration from hours, minutes, seconds, and nanoseconds.

Parameter

hours

rules.Integer

Hours portion of the duration.

Value must not be null.

mins

rules.Integer

Minutes portion of the duration.

Value must not be null.

secs

rules.Integer

Seconds portion of the duration.

Value must not be null.

nanos

rules.Integer

Nanoseconds portion of the duration.

Value must not be null.

Returns

non-null rules.Duration a Duration.

value

static

value(magnitude, unit) returns rules.Duration

Create a duration from a numeric magnitude and string unit.


Unit Description
w Weeks
d Days
h Hours
m Minutes
s Seconds
ms Milliseconds
ns Nanoseconds

Parameter

magnitude

rules.Integer

Unitless magnitude of the duration.

Value must not be null.

unit

rules.String

Unit of the duration.

Value must not be null.

Returns

non-null rules.Duration a Duration.

Example

duration.value(1, 'w') // Create a duration for 1 week of time.