rules. duration
Globally available duration functions. These functions are accessed using the
duration. prefix.
Methods
abs
abs(duration) returns rules.Duration
Absolute value of a duration.
Parameter |
|
|---|---|
|
duration |
Duration value. Value must not be null. |
- Returns
-
non-null rules.Durationthe absolute duration value of the input.
Example
duration.abs(duration.value(-10, 's')) == duration.value(10, 's')time
time(hours, mins, secs, nanos) returns rules.Duration
Create a duration from hours, minutes, seconds, and nanoseconds.
Parameter |
|
|---|---|
|
hours |
Hours portion of the duration. Value must not be null. |
|
mins |
Minutes portion of the duration. Value must not be null. |
|
secs |
Seconds portion of the duration. Value must not be null. |
|
nanos |
Nanoseconds portion of the duration. Value must not be null. |
- Returns
-
non-null rules.Durationa Duration.
value
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 |
Unitless magnitude of the duration. Value must not be null. |
|
unit |
Unit of the duration. Value must not be null. |
- Returns
-
non-null rules.Durationa Duration.
Example
duration.value(1, 'w') // Create a duration for 1 week of time.