timezone
0.11.2, released 6 weeks ago by tools.dart.dev
Time zone databases and time zone aware DateTime class in Dart.
What it does
Provides the IANA time zone database and a TZDateTime class that implements DateTime with support for different locations and time zones. Offers multiple database variants (default, all, 10y) and specific initialization options for Dart libraries, browsers, and standalone environments.
AI-written summary of version 0.11.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to handle dates and times across multiple specific world time zones.
- Your application requires accurate historical or future Daylight Saving Time (DST) rules.
Skip it when
- You only need basic UTC or local device time without specific time zone database lookups.
- You need to automatically detect the current time zone of the device natively without platform-dependent configuration.
Strengths
- Includes comprehensive IANA time zone database variants (default, all, 10y).
- TZDateTime implements the core DateTime interface for seamless drop-in usage.
Weaknesses
- Getting the current timezone of the device is platform-dependent and not a goal of the package.
- Standalone environment initialization likely will not work in a Flutter environment.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Requires initializing a time zone database variant before use via the appropriate library import (e.g., package:timezone/data/latest.dart).
import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
void main() {
tz.initializeTimeZones();
var detroit = tz.getLocation('America/Detroit');
var now = tz.TZDateTime.now(detroit);
}Alternatives
Packages that do the same job and could replace timezone.
- tempo
A time and date solution replacing core DateTime with advanced arithmetic and time zone support.
71Compare - get_time_ago
Relative time formatting for Dart and Flutter supporting 22 locales and CLDR plurals.
82Compare - ntp_dart
Cross-platform NTP and SNTP time synchronization client for Dart and Flutter.
73Compare - sugar
Standard library extension for date-times, timezones, collections, and monads.
68Compare
Works with
Packages commonly used together with timezone: ones it builds on, ones built on it, and its own family.
- flutter_local_notificationsBuilt on timezoneCross-platform plugin for displaying and scheduling local notifications.
- flutter_local_notifications_platform_interfaceBuilt on timezoneA common platform interface for the flutter_local_notifications plugin.
- syncfusion_flutter_calendarBuilt on timezoneFlutter Calendar widget with multiple views and appointment management
- device_calendarBuilt on timezoneFlutter plugin to read, create, update, and delete calendars and events on Android and iOS devices.
- timezone_to_countryBuilt on timezoneTranslate IANA time‑zone IDs to ISO 3166‑1 alpha‑2 country codes.
- kalenderBuilt on timezoneA customizable calendar widget with day, multi-day, month, and schedule views.
- liquifyBuilt on timezoneA powerful and extensible Liquid template engine for Dart.
- bones_apiBuilt on timezoneA powerful API backend framework for Dart with HTTP server, routing, SQL translator, and DB adapters.