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:

Members

(private, static, readonly) _referenceTime :number

The clock's referenceTime is the time when the module was loaded (in seconds).
Type:
  • number
Source:

Methods

(static) getDateStr(formatopt) → {string}

Get the clock's current time as a formatted string.

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

Parameters:
Name Type Attributes Default Description
format string <optional>
'YYYY-MM-DD_HH[h]mm.ss.SSS' the format for the string (see momentjs.com for details)
Source:
Returns:
a string representing the current time in the given format
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