A time value given in nanosecond precision. To prevent overflow (which would occur for time intervals spanning more than 0.29 years if a single JavaScript number, which has 2^53 bits of precision, were to be used), we use two numbers to store a time value. The first number denotes the number of whole seconds in the interval; the second number denotes the remaining number of nanoseconds in the interval. This class serves as a base class for UnitBasedTimeValue, which provides the convenience of defining time values as a single number accompanied by a unit.

  • TimeUnit
  • UnitBasedTimeValue

Constructors

  • Create a new time value. Both parameters must be non-negative integers; an error will be thrown otherwise. The second parameter is optional.

    Parameters

    • seconds: number

      Number of seconds in the interval.

    • nanoseconds: number = 0

      Remaining number of nanoseconds (defaults to zero).

    Returns TimeValue

Properties

nanoseconds: number = 0

Remaining number of nanoseconds (defaults to zero).

seconds: number

Number of seconds in the interval.

Methods

  • Return a new time value that denotes the duration of the time interval encoded by this time value plus the time interval encoded by the time value given as a parameter.

    Parameters

    • other: TimeValue

      The time value to add to this one.

    Returns TimeValue

  • Return true if this time value denotes a time interval of equal length as the interval encoded by the time value given as a parameter.

    Parameters

    • other: TimeValue

      The time value to compare to this one.

    Returns boolean

  • Returns boolean

  • Return true if this time value is later than the time given as a parameter.

    Parameters

    • other: TimeValue

      The time value to compare to this one.

    Returns boolean

  • Returns boolean

  • Return true if this denotes a time interval of length zero.

    Returns boolean

  • Return a new time value that denotes the duration of the time interval encoded by this time value minus the time interval encoded by the time value given as a parameter.

    Parameters

    • other: TimeValue

      The time value to subtract from this one.

    Returns TimeValue

  • Get a 64 bit binary, little endian representation of this TimeValue. Used by federates.

    Returns Buffer

  • Return a millisecond representation of this time value.

    Returns number

  • Print the number of seconds and nanoseconds in the time interval encoded by this time value.

    Returns string

  • Return a tuple that holds the seconds and remaining nanoseconds that jointly represent this time value.

    Returns [number, number]

  • Create a TimeValue from a 64bit little endian unsigned integer in a buffer.

    Parameters

    • buffer: Buffer

      A 64 bit unsigned integer. Little endian.

    Returns TimeValue

  • Give a value and time unit, return a new time value.

    The value is a number that is required to be a positive integer. The time unit must be a member of the TimeUnit enum.

    Parameters

    • value: number

      A number (which must be a positive integer) that denotes the length of the specified time interval, expressed as a multiple of the given time unit.

    • unit: TimeUnit

      The unit of measurement that applies to the given value.

    Returns TimeValue