couch-kit
    Preparing search index...

    Function calculateTimeSync

    • Computes the clock offset and round-trip time between client and server.

      Uses a simplified NTP-style calculation:

      • RTT = clientReceiveTime - clientSendTime
      • Offset = (serverTime + RTT/2) - clientReceiveTime

      Parameters

      • clientSendTime: number

        Timestamp (ms) when the PING was sent.

      • clientReceiveTime: number

        Timestamp (ms) when the PONG was received.

      • serverTime: number

        Server timestamp (ms) included in the PONG payload.

      Returns { offset: number; rtt: number }

      An object with offset (ms to add to Date.now() for server time) and rtt (round-trip time in ms).