tempo_dart

Status: 0.1.0 — all 8 modules implemented (390 tests passing).

A lightweight, tree-shakable date and time utility library for Dart and Flutter, philosophically modelled on @formkit/tempo for JavaScript.

tempo_dart works with the native DateTime primitive throughout — no wrapper types, no conversion overhead. Each capability lives in its own module that can be imported individually for minimal bundle size.

Features

  • Token-based and locale-aware formatting (format)
  • Pattern-based and auto-detect parsing (parse)
  • Immutable date arithmetic with month-overflow guard (modify)
  • Calendar-aware difference calculation (diff)
  • Readable boolean predicates (compare)
  • Localised relative-time strings (humanize) — built-in en, fr
  • Localised duration formatting (duration_format) — built-in en, fr

Zero runtime dependencies beyond intl and meta. Pure Dart — works on every Flutter target and on the Dart VM / server / CLI.

Install

dependencies:
  tempo_dart: ^0.1.0

Quick example

import 'package:intl/date_symbol_data_local.dart';
import 'package:tempo_dart/tempo_dart.dart';

Future<void> main() async {
  // Locale-aware tokens require `initializeDateFormatting` once at startup.
  await initializeDateFormatting('en');

  final now = DateTime(2026, 5, 8, 14, 5);
  print(now.format('dddd, MMMM D, YYYY'));         // Friday, May 8, 2026
  print(now.addMonths(1).endOfMonth());            // 2026-06-30 23:59:59.999999
  print(now.diffInDays(DateTime(2026, 5, 1)));     // 7
  print(
    now.humanize(
      relativeTo: DateTime(2026, 5, 8, 17, 5),
      locale: 'en',
    ),
  );                                                // 3 hours ago
}

A runnable copy lives at example/main.dart.

Run the tests

dart test

Currently 390 tests pass.

Design

See DESIGN.md for the implementation roadmap, status table, and notes on friction points the implementation hit. The full technical specification has module-by-module API details.

License

MIT — Copyright (c) 2026 Farai Macheka. See LICENSE.

Libraries

tempo_dart
tempo_dart — a lightweight, tree-shakable date and time utility library built around Dart's native DateTime.