Metakit / Domain types and row aggregates
Timezone-free dates (CalendarDay)
CalendarDay.schema stores calendar dates as integer days since 1970-01-01 (no hours, minutes, or local timezone offsets).
import { CalendarDay } from '@doeixd/metakit/domain'
const Booking = Schema.Struct({
checkIn: CalendarDay.schema,
checkOut: CalendarDay.schema,
}).pipe(Expr.refine($ => CalendarDay.before($.checkIn, $.checkOut)))
const checkIn = CalendarDay.parseIsoUnsafe('2026-06-01')
const checkOut = CalendarDay.parseIsoUnsafe('2026-06-05')
const valid = Schema.is(Booking)({ checkIn, checkOut })
const shown = CalendarDay.toIso(checkOut)
// valid -> true, shown -> Result.succeed('2026-06-05')CalendarDay.fromIso and CalendarDay.toIso cover years 0001 to 9999 (CalendarDay.earliest to CalendarDay.latest). Both return a Result: fromIso fails on a day the month does not have, and toIso on a day outside that range or one that is not an integer. The Schema itself holds any safe integer.
CalendarDay.addDays and CalendarDay.diffDays lower directly to integer num.add and num.sub, so the zone checker (a built-in arithmetic prover) and Z3 can prove date-range invariants like checkOut = checkIn + nights preserves checkIn < checkOut.
Pass domain values between copies of MetaKit
Each copy of MetaKit exports its own CalendarDayBrand, DecimalScaleBrand, and MoneyBrand symbols. If two packages load different copies, pass the integer value and call Schema.decodeUnknownSync with the receiving copy's domain Schema. Use CalendarDay.schema for epoch days, or construct the Decimal or Money Schema with the original scale and, for money, currency. The integer alone carries neither scale nor currency.