Class: Clock

time.Clock

A clock provides access to the current timestamp.

Methods

add(offsetDuration)

Adds a duration to the current timestamp of the clock.

Parameters:
Name Type Description
offsetDuration Duration | string | number

The duration or number of millis to add.

date() → {Date}

Returns the current timestamp of the clock.

Returns:

The current timestamp.

Type
Date

millis() → {number}

Returns the current timestamp of the clock in milliseconds.

Returns:

The current timestamp in milliseconds.

Type
number

(static) fixed(dateopt) → {Clock}

Creates a clock using a fixed date.

Parameters:
Name Type Attributes Default Description
date Date <optional>
'2024-02-21T19:16:00Z'

The fixed date of the clock.

See:
  • Clock#add
Returns:

A clock that returns alaways a fixed date.

Type
Clock

(static) system() → {Clock}

Creates a clock using system clock.

Returns:

A clock that uses system clock.

Type
Clock