code: function calculateClockOffset() {
    const start = Date.now();
    let cur = start;
    // Limit the iterations, just in case we're running in an environment where Date.now() has been mocked and is
    // constant.
    for (let i = 0; i < 1e6 && cur === start; i++) {
      cur = Date.now();
    }
  
    // At this point |cur| "just" became equal to the next millisecond -- the unseen digits after |cur| are approximately
    // all 0, and |cur| is the closest to the actual value of the UNIX time. Now, get the current global monotonic clock
    // value and do the remaining calculations.
  
    return cur - getGlobalMonotonicClockMS();
  }
docs: This function assumes the clock is accurate.