Constructor
new Timestamp()
Constructor accepts any of the following argument types:
new Timestamp(buffer[, offset=0]) | Buffer, with byte offset, holding 64-bit, big-endian encoded timestamp |
new Timestamp(Uint8Array[, offset=0]) | Uint8Array, with byte offset, holding 64-bit, big-endian encoded timestamp |
new Timestamp(seconds, nanoseconds) | Seconds (and nanoseconds fraction) since the Epoch |
new Timestamp(Date) | Date object representing timestamp |
new Timestamp(Int64) | Int64 object holding 64-bit, big-endian encoded timestamp |
- Source:
Members
(static, constant) TIMESTAMP_AUTO :Timestamp
Auto-assign timestamp constant (INT64_MIN+2).
Type:
- Source:
(static, constant) TIMESTAMP_MAX :Timestamp
Maximum timestamp constant (INT64_MAX).
Type:
- Source:
(static, constant) TIMESTAMP_MIN :Timestamp
Minimum timestamp constant (INT64_MIN).
Type:
- Source:
(static, constant) TIMESTAMP_NULL :Timestamp
NULL timestamp constant (INT64_MIN+1).
Type:
- Source:
buffer :Buffer
Holds 8 byte timestamp in big-endian order.
Type:
- Buffer
- Source:
nanoseconds :Number
Nanosecond portion (sub-second) of nanoseconds since Epoch. Used in
combination with seconds to obtain full
resolution timestamp.
Type:
- Number
- Source:
offset :Number
Offset within buffer of beginning of timestamp bytes.
Type:
- Number
- Source:
seconds :Number
Seconds since the Epoch.
Type:
- Number
- Source:
Methods
bufferToSeconds()
- Source:
compare(other) → {Number}
Compares this object with other object. Performs a bytewise comparison of
the underlying buffers.
Parameters:
Name | Type | Description |
---|---|---|
other |
Int64 | Other Int64 derived object with which to compare |
- Source:
Returns:
Number less than 0, equal to 0, or greater than 0, depending
of whether this object is less than, equal to, or greater than other.
- Type
- Number
copyLE(targetBuffer, targetOffsetopt)
Copy 8 bytes of int64 in little-endian order into
targetBuffer
starting at targetOffset
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
targetBuffer |
Buffer | Buffer to copy into. | ||
targetOffset |
number |
<optional> |
0 | Offset into target buffer. |
- Source:
equals(other) → {Boolean}
Equality test of this object with other object. Performs a bytewise comparison of
the underlying buffers.
Parameters:
Name | Type | Description |
---|---|---|
other |
Int64 | Other Int64 derived object with which to compare |
- Source:
Returns:
true if equal, false otherwise
- Type
- Boolean
getNanoseconds() → {Number}
Returns nanosecond portion (sub-second) of timestamp.
If nanoseconds is undefined,
bufferToSeconds() is first called to
populated it.
- Source:
Returns:
Nanosecond portion (sub-second) of timestamp.
- Type
- Number
getSeconds() → {Number}
Returns number of seconds since the Epoch (seconds).
If seconds is undefined,
bufferToSeconds() is first called to
populated it.
- Source:
Returns:
Number of seconds since the Epoch.
- Type
- Number
setSeconds(seconds, nanoseconds)
Sets timestamp from seconds and nanoseconds (fraction of one second). Sets
seconds and
nanoseconds members and stores the combined
nanoseconds since the Epoch number as a 64-bit integer in big-endian order
starting at offset within
buffer, creating the buffer if necessary.
Parameters:
Name | Type | Description |
---|---|---|
seconds |
Seconds since Epoch. | |
nanoseconds |
Nanosecond portion (sub-second) of nanoseconds since Epoch. |
- Source:
toDate() → {Date}
Returns Date object representing this timestamp rounded to milliseconds.
- Source:
Returns:
Newly allocated Date object representing this timestamp
rounded to milliseconds.
- Type
- Date
toString(radixopt)
Return string representation of timestamp. The
radix
value of
10 is handled specially and returns the full resolution timstamp in digits.
A radix
value of 16 is handled with a call to
this.toOctetString()
. Otherwise, the result of
valueOf().toString(radix)
is returned.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
radix |
Number |
<optional> |
10 | Just like Number.toString() radix |
- Source: