Skip to content
pubscout

time_machine2

0.14.0, released 9 months ago by evoleen.com

Comprehensive date and time library with support for timezones, calendars, cultures, and parsing.

WASM-ready
$ flutter pub add time_machine2
Source repository

What it does

Provides an alternative date and time API over Dart Core with support for time zones, calendars, cultures, formatting, and parsing. It includes an embedded copy of the IANA time zone database and Unicode CLDR patterns, avoiding simplistic platform limitations.

AI-written summary of version 0.14.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need precise date and time arithmetic across multiple calendars and time zones.
  • You require robust parsing and formatting with locale-aware cultures.

Skip it when

  • You only need basic, current local time or simple UTC timestamps without time zone mapping.
  • You want to avoid initializing library assets at startup.

Strengths

  • Includes embedded IANA time zone database and culture rules.
  • Type-safe classes prevent mixing timestamps incorrectly.
  • Supports platforms across Flutter, Web, and Server.

Weaknesses

  • Requires manual asynchronous initialization before use.
  • API can be complex compared to native DateTime.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5

Must call await TimeMachine.initialize() early in main. For Flutter, rootBundle must be provided in the initialization map.

await TimeMachine.initialize();
final now = Instant.now();
final tomorrow = now.add(Time(days: 1));

Alternatives

Packages that do the same job and could replace time_machine2.

  • time_machine

    Date and time library with support for timezones, calendars, cultures, formatting and parsing.

  • jiffy

    Parse, manipulate, query, and format dates and times in Dart and Flutter.

  • money2

    High-precision library for storing, parsing, formatting, and performing arithmetic on money.

  • sugar

    Standard library extension for date-times, timezones, collections, and monads.

Works with

Packages commonly used together with time_machine2: ones it builds on, ones built on it, and its own family.