Skip to main content

timezone_extensions 0.2.1 copy "timezone_extensions: ^0.2.1" to clipboard
timezone_extensions: ^0.2.1 copied to clipboard

Add-on for package:timezone — convert a TZDateTime from one Location to another, and look up English generic, standard, and daylight zone names.

timezone_extensions #

An add-on for package:timezone: convert a TZDateTime to another Location, and read English time zone names.

Initialization #

⚠️ Load the latest_all tzdata from package:timezone, not the default latest. latest omits tzdb links, including Europe/Amsterdam, Europe/Stockholm, and US/Pacific.

VM and Flutter (including Flutter web) #

import 'package:timezone/data/latest_all.dart' as tz;
import 'package:timezone/timezone.dart';
import 'package:timezone_extensions/timezone_extensions.dart';

void main() {
  tz.initializeTimeZones();
}

Web (Dart) #

import 'package:timezone/browser.dart' as tz;
import 'package:timezone/timezone.dart';
import 'package:timezone_extensions/timezone_extensions.dart';

Future<void> main() async {
  await tz.initializeTimeZone('packages/timezone/data/latest_all.tzf');
}

API #

Time zone names #

A Location is a place. A TZDateTime is a place and a moment.

  • Location.timeZoneGenericName — one name all year (Pacific Time, India Standard Time); a zone that observes DST inside a metazone with no daylight name gets the standard name (Europe/London is Greenwich Mean Time).
  • TZDateTime.timeZoneSpecificName — standard or daylight name at that moment: Pacific Daylight Time, Central European Summer Time.
  • TZDateTime.utcOffsetLabel — UTC-07, UTC+04:30, UTC.

TZDateTime.timeZoneName from package:timezone is one abbreviation: letters (PDT) or digits (-03). Location.timeZoneGenericName and TZDateTime.timeZoneSpecificName are null when CLDR has no label, including no daylight label during DST (Jersey in July). timeZoneSpecificName ?? utcOffsetLabel is never null.

final officeLocation = getLocation('America/Los_Angeles');

print(officeLocation.name);                // America/Los_Angeles
print(officeLocation.timeZoneGenericName); // Pacific Time

final confCallStart = TZDateTime(officeLocation, 2026, 8, 14, 18, 30);

print(confCallStart);                      // 2026-08-14 18:30:00.000-0700
print(confCallStart.timeZoneSpecificName); // Pacific Daylight Time
print(confCallStart.timeZoneName);         // PDT
print(confCallStart.utcOffsetLabel);       // UTC-07

Convert to another clock #

  • TZDateTime.toLocation(location) — the same instant on location's clock, like toUtc / toLocal.
  • TZDateTime.offsetDifference(location) — how far ahead location's clock is at this instant (negative if behind). Not difference.
final clientLocation = getLocation('Australia/Sydney');
final confCallStartForClient = confCallStart.toLocation(clientLocation);

print(confCallStartForClient);                      // 2026-08-15 11:30:00.000+1000
print(confCallStartForClient.timeZoneSpecificName); // Australian Eastern Standard Time
print(confCallStartForClient.timeZoneName);         // AEST
print(confCallStartForClient.utcOffsetLabel);       // UTC+10

Data #

English names come from Unicode CLDR. cldrVersion is that release, not the tzdb version in package:timezone. Offsets, DST rules, and abbreviations (TZDateTime.timeZoneName) come from package:timezone.

Licenses #

0
likes
160
points
822
downloads

Documentation

API reference

Publisher

verified publisherg.watch

Weekly Downloads

Add-on for package:timezone — convert a TZDateTime from one Location to another, and look up English generic, standard, and daylight zone names.

Repository (GitHub)
View/report issues

Topics

#timezone #iana

License

MIT (license)

Dependencies

timezone

More

Packages that depend on timezone_extensions