clock.ts
This file
Path
packages/testkit/src/clock.ts
17 lines · 646 bytes · TypeScript
Last changed by
Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 1–17why, one step back1import { DateTime, Duration } from "effect";2import type { Effect } from "effect";3import { TestClock } from "effect/testing";45export const at = (iso: string): DateTime.Utc =>6 DateTime.toUtc(DateTime.makeUnsafe(iso));78export const defaultNow: DateTime.Utc = at("2026-10-07T12:00:00Z");910/**11 * Moves the TestClock to an instant, waking everything that sleeps until then:12 * `advanceTo("2026-10-07T14:00:00Z")` lets a claim's two-hour alarm fire.13 */14export const advanceTo = (iso: string): Effect.Effect<void> =>15 TestClock.setTime(DateTime.toEpochMillis(at(iso)));1617export const hours = (n: number): Duration.Duration => Duration.hours(n);