Absolute value - if this is a negative duration, then return its positive value.
Return ticks().
Negative of this. Shortcut is -a.
Return number of nanosecond ticks.
Get this Duration as a Fantom code literal.
Get this duration in 24 hour days. Any fractional days are truncated with a loss of precision.
Get this duration in hours. Any fractional hours are truncated with a loss of precision.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Format this duration according to ISO 8601. Also see fromIso.
Examples:
8ns.toIso => PT0.000000008S
100ms.toIso => PT0.1S
(-20sec).toIso => -PT20S
3.5min.toIso => PT3M30S
1day.toIso => PT24H
(1day+2hr+3min).toIso => P1DT2H3M
Return human friendly string representation. TODO: enhance this for pattern
Get this duration in milliseconds. Any fractional milliseconds are truncated with a loss of precision.
Get this duration in minutes. Any fractional minutes are truncated with a loss of precision.
Get this duration in seconds. Any fractional seconds are truncated with a loss of precision.
Return string representation of the duration which is a valid duration literal format suitable for decoding via fromStr.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
bootGet the system timer at boot time of the Fantom VM.
Static
defDefault value is 0ns.
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
fromParse a duration according to ISO 8601. If invalid format and checked is false return null, otherwise throw ParseErr. The following restrictions are enforced:
Y
year or M
month component since it is
ambiguousS
seconds component may include a fractionOptional
checked: booleanStatic
fromParse a Str into a Duration according to the Fantom literal format. If invalid format and checked is false return null, otherwise throw ParseErr. The following suffixes are supported:
ns: nanoseconds (x 1)
ms: milliseconds (x 1,000,000)
sec: seconds (x 1,000,000,000)
min: minutes (x 60,000,000,000)
hr: hours (x 3,600,000,000,000)
day: days (x 86,400,000,000,000)
Examples:
Duration.fromStr("4ns")
Duration.fromStr("100ms")
Duration.fromStr("-0.5hr")
Optional
checked: booleanStatic
makeCreate a Duration which represents the specified number of nanosecond ticks.
Static
maxMax value is equivalent to make(Int.maxVal)
.
Static
minMin value is equivalent to make(Int.minVal)
.
Static
nowGet the current value of the system timer. This method returns a relative time unrelated to system or wall-clock time. Typically it is the number of nanosecond ticks which have elapsed since system startup.
Static
nowConvenience for now.ticks
.
Static
uptimeGet the duration which has elapsed since the Fantom VM was
booted which is now - boot
.
Duration represents a relative duration of time with nanosecond precision.
Also see docLang.