tz_datetime 1.1.0 copy "tz_datetime: ^1.1.0" to clipboard
tz_datetime: ^1.1.0 copied to clipboard

A Dart package for handling time zoned datetime using native platform implementations

tz_datetime #

A lightweight, cross-platform timezone-aware datetime package for Dart and Flutter applications.

This package serves as an alternative to the Timezone package with enhanced performance characteristics and improved resource efficiency.

Key Benefits #

  • App Size: No embedded IANA database in your app, keeping your application footprint small
  • Memory Efficiency: IANA database is not loaded into memory, reducing RAM usage
  • Fast Startup: Nothing to load before working with dates & timezones, improving app launch times
  • Native Integration: Provides seamless calls to dedicated platform APIs
  • Complete Data: No compromise on truncated databases - full timezone information available
  • Minimal Dependencies: Only lightweight bindings to platform-specific implementations

API Compatibility #

The API is designed to be very similar to the Timezone package, making migration straightforward.

Tests are adapted from the original package to ensure reliability and compatibility.

Usage #

Basic usage example:

import 'package:tz_datetime/tz_datetime.dart';

void main() {
  final la = 'America/Los_Angeles';
  final ny = 'America/New_York';

  // Retrieve all available zones form platform
  final zones = TzDatetime.getAvailableTimezones();  // [Africa/Abidjan, Europe/Athens, ...]
  
  // Get offset from any date with Daylight Saving Times
  Duration offset = TzDatetime.getOffset(DateTime.now(), la);  // -8:00:00.000000

  final laTime = TzDatetime.now(la);  // 2026-02-09T03:17:03.964038-0800

  final nyTime = TzDatetime.from(laTime, ny);  // 2026-02-09T06:17:03.964038-0500
}

For more, see the API documentation.

Platform Support #

Platform Database Type Requirement
Android Native SDK 21.0+
iOS Native SDK 8.0+
Linux Native '/usr/share/zoneinfo' DB location.
macOS Native SDK 10.10+
Web Native Browser 2021 (Desktop), 2023 (Mobile)
Windows Native Windows 10 1703+ (2017)

On all platforms, the package leverages native system timezone databases for accuracy and efficiency.

Contributing #

Contributions are always welcome!

License #

This project is licensed under the BSD license.

5
likes
160
points
146
downloads

Documentation

API reference

Publisher

verified publishercow-level.ovh

Weekly Downloads

A Dart package for handling time zoned datetime using native platform implementations

Repository (GitHub)
View/report issues

Topics

#timezone #iana #date #datetime

License

BSD-2-Clause (license)

Dependencies

tz_datetime_android, tz_datetime_darwin, tz_datetime_linux, tz_datetime_platform_interface, tz_datetime_web, tz_datetime_windows

More

Packages that depend on tz_datetime