API reference › @evolu/common › local‑first/Timestamp › receiveTimestamp
function receiveTimestamp(
deps: TimestampConfigDep,
): (
local: Timestamp,
remote: Timestamp,
now: number &
Brand<"NonNaN"> &
Brand<"Finite"> &
Brand<"Int"> &
Brand<"NonNegative"> &
Brand<"LessThan281474976710655"> &
Brand<"Millis">,
) => Result<Timestamp, TimestampError>;
Defined in: packages/common/src/local-first/Timestamp.ts:580
Advances a Timestamp for a received one.
Rejects remote drift with TimestampDriftError and cause: "remote"
before clock arithmetic. Merges the later clock state, preserves the local
node ID, and uses sendTimestamp to advance and validate the result. An
already-ahead local clock or rollover beyond the drift limit returns local
drift. Pass one captured time for a batch or replay.
Example
import { assertErr, Millis } from "@evolu/common";
import { createTimestamp, receiveTimestamp } from "@evolu/common/local-first";
const receive = receiveTimestamp({ timestampConfig: { maxDrift: 10 } });
const local = createTimestamp();
const remote = createTimestamp({ millis: Millis.orThrow(111) });
assertErr(receive(local, remote, Millis.orThrow(100)), {
type: "TimestampDriftError",
timestamp: remote,
cause: "remote",
now: Millis.orThrow(100),
});