zedkit
@zedtech/zedkit-core

Inject time in domain code

A tiny `Clock` port with production and fixed implementations.

beta

At a glance

  • Who: Developers who need deterministic dates in tests without mocking Date globally.
  • What: A tiny Clock port 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-core

Latest: 0.1.3 (via changesets).

Example

Usage
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)

On this page