@haxall/haxall
    Preparing search index...

    Class Time

    Time represents a time of day independent of a specific date or timezone.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Compare based on hour, min, sec, and ns values.

      Parameters

      Returns number

    • Two times are equal if have identical hour, min, sec, and ns values.

      Parameters

      Returns boolean

    • Return hash of hour, min, sec, and ns values.

      Returns number

    • Get the hour of the time as a number between 0 and 23.

      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 if "00:00:00" which is equal to defVal.

      Returns boolean

    • Get the minutes of the time as a number between 0 and 59.

      Returns number

    • Subtract the specified duration to this time. Throw ArgErr if dur is not between 0 and 24hr. Overflows will rollover.

      Example:

      Time(5,0,0) - 30min  =>  04:30:00
      

      Parameters

      Returns Time

    • Get the number of nanoseconds (the fraction of seconds) as a number between 0 and 999,999,999.

      Returns number

    • Add the specified duration to this time. Throw ArgErr if dur is not between 0 and 24hr. Overflows will rollover.

      Example:

      Time(5,0,0) + 30min  =>  05:30:00
      

      Parameters

      Returns Time

    • Get the whole seconds of the time as a number between 0 and 59.

      Returns number

    • Get this Time as a Fantom expression suitable for code generation.

      Returns string

    • Combine this Time with the given Date to return a DateTime.

      Parameters

      Returns DateTime

    • Return the duration of time which has elapsed since midnight. See fromDuration.

      Example:

      Time(2, 30).toDuration  =>  150min
      

      Returns Duration

    • 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 instance according to ISO 8601 using the pattern:

      hh:mm:ss.FFFFFFFFF
      

      Also see fromIso and toStr.

      Returns string

    • Format this date according to the specified pattern. If pattern is null, then a localized default is used. The pattern format is the same as DateTime.toLocale:

      h      One digit 24 hour (0-23)   3, 22
      hh Two digit 24 hour (0-23) 03, 22
      k One digit 12 hour (1-12) 3, 11
      kk Two digit 12 hour (1-12) 03, 11
      m One digit minutes (0-59) 4, 45
      mm Two digit minutes (0-59) 04, 45
      s One digit seconds (0-59) 4, 45
      ss Two digit seconds (0-59) 04, 45
      SS Optional seconds (only if non-zero)
      f* Fractional secs trailing zeros
      F* Fractional secs no trailing zeros
      a Lower case a/p for am/pm a, p
      aa Lower case am/pm am, pm
      A Upper case A/P for am/pm A, P
      AA Upper case AM/PM AM, PM
      'xyz' Literal characters

      A symbol immediately preceding a "F" pattern with no fraction to print is skipped.

      Parameters

      • Optionalpattern: string
      • Optionallocale: Locale

      Returns string

    • Return programmatic ISO 8601 string encoding formatted as follows:

      hh:mm:ss.FFFFFFFFF
      12:06:00.0

      Also see fromStr, toIso, and toLocale.

      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

    • Default value is "00:00:00".

      Returns Time

    • 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

    • Translate a duration of time which has elapsed since midnight into a Time of day. See toDuration. If the duration is not between 0 and 24hr throw ArgErr.

      Example:

      Time.fromDuration(150min)  =>  02:30:00
      

      Parameters

      Returns Time

    • Parse an ISO 8601 time. If invalid format and checked is false return null, otherwise throw ParseErr. The following format is supported:

      hh:mm:ss.FFFFFFFFF
      

      Also see toIso and fromStr.

      Parameters

      • s: string
      • Optionalchecked: boolean

      Returns Time

    • Parse a string into a Time using the given pattern. If string is not a valid format then return null or raise ParseErr based on checked flag. See toLocale for pattern syntax.

      Parameters

      • str: string
      • pattern: string
      • Optionalchecked: boolean

      Returns Time

    • Parse the string into a Time from the programmatic encoding defined by toStr. If the string cannot be parsed into a valid Time and checked is false then return null, otherwise throw ParseErr.

      Parameters

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

      Returns Time

    • Make for the specified time values:

      • hour: 0-23
      • min: 0-59
      • sec: 0-59
      • ns: 0-999_999_999

      Throw ArgErr if any of the parameters are out of range.

      Parameters

      • hour: number
      • min: number
      • Optionalsec: number
      • Optionalns: number
      • ...args: unknown[]

      Returns Time

    • Get the current time using the specified timezone. This method may use DateTime.now with the default tolerance 250ms.

      Parameters

      Returns Time