Skip to content
CIVersionSizeTypeScriptDependencies
Timit logo

Timit

⚡ Quick Reference

Package: @vielzeug/timit  ·  Category: Date Time

Key exports: parse, convert, add, subtract, diff, format, isBefore, isAfter, isWithin, now

When to use: Temporal-powered date parsing, DST-safe arithmetic, timezone conversion, and Intl formatting.

Related: Toolkit

@vielzeug/timit is a Temporal-first date/time library for TypeScript. It provides explicit helpers for parsing local values, timezone conversion, DST-safe arithmetic, comparison, boundaries, and Intl-based formatting.

Installation

sh
pnpm add @vielzeug/timit
sh
npm install @vielzeug/timit
sh
yarn add @vielzeug/timit

Quick Start

ts
import { formatHuman, formatInstant, now, shift, toZoned } from '@vielzeug/timit';

// Get current time in a timezone
const meeting = toZoned(now('UTC'), { tz: 'America/New_York' });

// Shift time (DST-safe)
const reminder = shift(meeting, { minutes: -15 });

// Format for humans
const text = formatHuman(reminder, { pattern: 'short', locale: 'en-US', tz: 'America/New_York' });

// Format for APIs/logs (instant string)
const stable = formatInstant(reminder);

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 = shift(meeting, { minutes: -15 });
FeatureTimitdate-fnsDay.jsNative Date
Bundle size2.5 KB~10 kB~3 kB0 kB
DST-safe math✅ (Temporal)ManualManual
Timezone aware✅ Full supportPartial
Immutable
Format presets✅ ('short', 'medium', '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

  • Explicit local parsingparseLocal() for wall-clock values; local inputs require tz when converting
  • DST-safe arithmeticshift() handles transitions correctly
  • Timezone conversiontoZoned(), toInstant() with full timezone support
  • Formatting split by intentformatHuman() for UI, formatInstant() for instant strings, formatZoned() for zoned strings
  • Range + comparison helperswithin(), clamp(), isBefore(), isAfter(), isSame()
  • Boundary helpersstartOf() and endOf() for day/week/month/year-style snapping
  • Relative and duration formattingformatRelative() and formatDuration()
  • Duration toolsdifference() plus parseDuration()
  • Intl integration — formatting respects locale & calendar systems
  • Polyfilled Temporal — works in runtimes without native support via @js-temporal/polyfill
  • 2.5 KB gzipped

Compatibility

EnvironmentSupport
Browser
Node.js
SSR
Deno

Documentation

See Also

  • Validit — Schema validation (similar v namespace pattern)
  • Logit — Structured logging