Timit
@vielzeug/timit is a Temporal-first date/time library for TypeScript. It provides ergonomic helpers for parsing, timezone conversion, arithmetic through DST transitions, and Intl-based formatting—without the fragility of native Date.
Installation
sh
pnpm add @vielzeug/timitsh
npm install @vielzeug/timitsh
yarn add @vielzeug/timitQuick Start
ts
import { d } from '@vielzeug/timit';
// Get current time in a timezone
const meeting = d.asZoned(d.now(), { tz: 'America/New_York' });
// Add time (DST-safe)
const reminder = d.add(meeting, { minutes: -15 });
// Format for humans
const text = d.format(reminder, { pattern: 'short', locale: 'en-US' });Why Timit?
Manual date handling breaks at daylight-saving boundaries, timezone edges, and DST transitions.
ts
// Before — fragile, loses timezone context
const reminder = new Date(meeting.getTime() - 15 * 60_000);
// After — DST-safe, handles transitions correctly
const reminder = d.add(meeting, { minutes: -15 });| Feature | Timit | date-fns | Day.js | Native Date |
|---|---|---|---|---|
| Bundle size | 1.0 KB | ~10 kB | ~3 kB | 0 kB |
| DST-safe math | ✅ (Temporal) | Manual | Manual | ❌ |
| Timezone aware | ✅ Full support | ✅ | ✅ | Partial |
| Immutable | ✅ | ✅ | ✅ | ❌ |
| Format presets | ✅ ('short', 'long', etc.) | ❌ | ❌ | ❌ |
| Type inference | ✅ Full TypeScript | Partial | Partial | ❌ |
Use Timit when you need reliable timezone handling, DST-safe arithmetic, and clean Temporal-based APIs without heavy dependencies.
Consider alternatives when you need extensive locale data (date-fns).
Features
dnamespace — grouped functions for IDE autocomplete (like Validit'sv)- DST-safe arithmetic —
d.add(),d.subtract()handle transitions correctly - Timezone conversion —
d.asZoned(),d.asInstant()with full timezone support - Preset formatting —
'short','long','iso','date-only','time-only' - Range queries —
d.within()for inclusive time range checks - Duration diffs —
d.diff()with granular control over units - Intl integration — formatting respects locale & calendar systems
- Tree-shaking friendly — import
dor individual functions - Polyfilled Temporal — works in runtimes without native support via
@js-temporal/polyfill - 1.0 KB gzipped
Compatibility
| Environment | Support |
|---|---|
| Browser | ✅ |
| Node.js | ✅ |
| SSR | ✅ |
| Deno | ✅ |
See Also
- Usage Guide
- API Reference
- Examples
- Validit — Schema validation (similar
vnamespace pattern) - Logit — Structured logging