I can't seem to able to find detailed information on Sensor.timestamp
(MDN).
If you click through into the spec for High Resolution Time Level 2, these questions are answerable in regards to the timestamp
getter for Sensor
, which is returned as a DOMHighResTimeStamp
:
- Is the timestamp absolute or relative?
"Absolute" here is a bit vague, and I'm not sure what your reference point for this term would be. Formally defined, timestamp
is "measured relative from the time origin, global monotonic clock, or a time value that represents a duration between two DOMHighResTimeStamp
s". (Source)
- What is the zero value?
TL;DR - in this specific context, it should be the Unix epoch (1 Jan 1970 00:00:00 UTC).
This is a bit more complicated to answer and just a bit more opaque than is helpful, but the "zero value" for a DOMHighResTimeStamp
is referred to in the spec as a time origin. The formal definition of a time origin is a bit verbose; however in this context since Sensor
(or, more importantly, its derived classes) is not a Window
nor a WorkerGlobalScope
object, the time origin would be undefined
and thus (per the definition above) would default to something called the global monotonic clock which pins "zero" to the Unix epoch (1 Jan 1970 00:00:00 UTC) per the ECMA-262 definition of time
(§21.4.1.1).
- Are the values measured in milliseconds?
Yes - "The DOMHighResTimeStamp
type is used to store a time value in milliseconds" (Source).