@haxall/haxall
    Preparing search index...

    Class Duration

    Duration represents a relative duration of time with nanosecond precision.

    Also see docLang.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Absolute value - if this is a negative duration, then return its positive value.

      Returns Duration

    • Clamp this duration between the min and max. If it's less than min then return min, if it's greater than max return max, otherwise return this duration itself.

      Parameters

      Returns Duration

    • Compare based on nanosecond ticks.

      Parameters

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • b: number

      Returns Duration

    • Divide this by b. Shortcut is a/b.

      Parameters

      • b: number

      Returns Duration

    • Return true if same number nanosecond ticks.

      Parameters

      Returns boolean

    • Return a new Duration with this duration's nanosecond ticks truncated according to the specified accuracy. For example floor(1min) will truncate this duration such that its seconds are 0.0.

      Parameters

      Returns Duration

    • Return ticks().

      Returns number

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Return the maximum duration between this and that.

      Parameters

      Returns Duration

    • Return the minimum duration between this and that.

      Parameters

      Returns Duration

    • Subtract b from this. Shortcut is a-b.

      Parameters

      Returns Duration

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • b: number

      Returns Duration

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • b: number

      Returns Duration

    • Negative of this. Shortcut is -a.

      Returns Duration

    • Add this with b. Shortcut is a+b.

      Parameters

      Returns Duration

    • Return number of nanosecond ticks.

      Returns number

    • Get this Duration as a Fantom code literal.

      Returns string

    • Get this duration in 24 hour days. Any fractional days are truncated with a loss of precision.

      Returns number

    • Get this duration in hours. Any fractional hours are truncated with a loss of precision.

      Returns number

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • 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

      Returns string

    • Return human friendly string representation. TODO: enhance this for pattern

      Returns string

    • Get this duration in milliseconds. Any fractional milliseconds are truncated with a loss of precision.

      Returns number

    • Get this duration in minutes. Any fractional minutes are truncated with a loss of precision.

      Returns number

    • Get this duration in seconds. Any fractional seconds are truncated with a loss of precision.

      Returns number

    • Return string representation of the duration which is a valid duration literal format suitable for decoding via fromStr.

      Returns string

    • 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.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Get the system timer at boot time of the Fantom VM.

      Returns Duration

    • Default value is 0ns.

      Returns Duration

    • Write 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.

      Parameters

      Returns void

    • Parse a duration according to ISO 8601. If invalid format and checked is false return null, otherwise throw ParseErr. The following restrictions are enforced:

      • Cannot specify a Y year or M month component since it is ambiguous
      • Only the S seconds component may include a fraction
      • Only nanosecond resolution is supported See toIso for example formats.

      Parameters

      • s: string
      • Optionalchecked: boolean

      Returns Duration

    • Parse 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")

      Parameters

      • s: string
      • Optionalchecked: boolean
      • ...args: unknown[]

      Returns Duration

    • Create a Duration which represents the specified number of nanosecond ticks.

      Parameters

      • ticks: number
      • ...args: unknown[]

      Returns Duration

    • Max value is equivalent to make(Int.maxVal).

      Returns Duration

    • Min value is equivalent to make(Int.minVal).

      Returns Duration

    • Get 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.

      Returns Duration

    • Convenience for now.ticks.

      Returns number

    • Get the duration which has elapsed since the Fantom VM was booted which is now - boot.

      Returns Duration