Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
Docs: Document the HrTime format (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesJHPark authored Nov 8, 2021
1 parent 3507de7 commit 35582a7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/common/Time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Defines High-Resolution Time.
*
* The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
* The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
* The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds:
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
* The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
* This is represented in HrTime format as [1609504210, 150000000].
*/
export type HrTime = [number, number];

/**
Expand Down

0 comments on commit 35582a7

Please sign in to comment.