Skip to content
VersionSizeTypeScriptDependencies
Timit logo

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/timit
sh
npm install @vielzeug/timit
sh
yarn add @vielzeug/timit

Quick 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 });
FeatureTimitdate-fnsDay.jsNative Date
Bundle size1.0 KB~10 kB~3 kB0 kB
DST-safe math✅ (Temporal)ManualManual
Timezone aware✅ Full supportPartial
Immutable
Format presets✅ ('short', 'long', etc.)
Type inference✅ Full TypeScriptPartialPartial

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

  • d namespace — grouped functions for IDE autocomplete (like Validit's v)
  • DST-safe arithmeticd.add(), d.subtract() handle transitions correctly
  • Timezone conversiond.asZoned(), d.asInstant() with full timezone support
  • Preset formatting'short', 'long', 'iso', 'date-only', 'time-only'
  • Range queriesd.within() for inclusive time range checks
  • Duration diffsd.diff() with granular control over units
  • Intl integration — formatting respects locale & calendar systems
  • Tree-shaking friendly — import d or individual functions
  • Polyfilled Temporal — works in runtimes without native support via @js-temporal/polyfill
  • 1.0 KB gzipped

Compatibility

EnvironmentSupport
Browser
Node.js
SSR
Deno

See Also