Class: MonotonicClock

util.MonotonicClock(startTimeopt)

new MonotonicClock(startTimeopt)

MonotonicClock offers a convenient way to keep track of time during experiments. An experiment can have as many independent clocks as needed, e.g. one to time responses, another one to keep track of stimuli, etc.

Parameters:
Name Type Attributes Default Description
startTime number <optional>
<time elapsed since the reference point, i.e. the time when the module was loaded> the clock's start time (in ms)
Source:

Methods

(static) getDate(locales, options) → {string}

Get the current timestamp with language-sensitive formatting rules applied.

Note: This is just a convenience wrapper around `Intl.DateTimeFormat()`.

Parameters:
Name Type Description
locales string | array.string A string with a BCP 47 language tag, or an array of such strings.
options object An object with detailed date and time styling information.
Source:
Returns:
The current timestamp in the chosen format.
Type
string

(static) getDateStr() → {string}

Get the clock's current time in the default format filtering out file name unsafe characters.

Note: This is mostly used as an appendix to the name of the keys save to the server.

Source:
Returns:
A string representing the current time formatted as YYYY-MM-DD_HH[h]mm.ss.sss
Type
string

getLastResetTime() → {number}

Get the current offset being applied to the high resolution timebase used by this Clock.
Source:
Returns:
the offset (in seconds)
Type
number

getReferenceTime() → {number}

Get the time elapsed since the reference point.
Source:
Returns:
the time elapsed since the reference point (in seconds)
Type
number

getTime() → {number}

Get the current time on this clock.
Source:
Returns:
the current time (in seconds)
Type
number