@zedtech/zedkit-core
Inject time in domain code
A tiny `Clock` port with production and fixed implementations.
beta
Usage
At a glance
- Who: Developers who need deterministic dates in tests without mocking
Dateglobally. - What: A tiny
Clockport with production and fixed implementations. - Use when: When domain rules depend on "now" (expiry, windows, staleness).
- Avoid when: For one-off
Date.now()in infrastructure glue — keep those at the edges.
Install
pnpm add @zedtech/zedkit-coreLatest: 0.1.3 (via changesets).
Example
import { fixedClock, systemClock, type Clock } from "@zedtech/zedkit-core";
const clock: Clock = process.env.NODE_ENV === "test" ? fixedClock(new Date("2026-01-01")) : systemClock;
const ageMs = clock.now().getTime() - createdAt.getTime();Wraps: (none)