Skip to content

A lightweight package used for converting between Windows time zones and IANA time zone database format.

License

Notifications You must be signed in to change notification settings

FriesI23/win2iana_tz_converter

Repository files navigation

Win2IANA TZ Converter

Package Likes Popularity Points

win2iana_tz_converter is a lightweight package which used for converting between Windows time zones and IANA time zone database format.

Features

Including a built-in set of Windows to IANA conversion data for convenient direct use. And also provided a simple cache version implementation.

final TZConverter ct1 = TZConverter();
final TzConverterWithCache ct2 = TZConverter.cache();
final TzConverterWithCache ct3 = TZConverter.cacheWithParent(ct1);

You can also customize a set of data for conversion. Data format can be viewed here.

final db = {
  "supplemental": {
    "version": {"_unicodeVersion": "15.1.0", "_cldrVersion": "45"},
    "windowsZones": {
      "mapTimezones": [
        {
          "mapZone": {
            "_other": "Afghanistan Standard Time",
            "_type": "Asia/Kabul",
            "_territory": "001"
          }
        },
        // other mapZone
      ]
    }
  }
};
final TZConverter ct1 = TZConverter(db: db);
final TzConverterWithCache ct2 = TZConverter.cache(db: db);

Getting started

Add dependency with dart pub add command

dart pub add win2iana_tz_converter

Or Add below line to pubspec.yaml

dependencies:
  ...
  win2iana_tz_converter: any  # or special version

Then run dart pub get, or flutter pub get for flutter project.

Usage

final TZConverter ct = TZConverter();
final win2ianaResult =
    ct.windowsToIana("China Standard Time").map((e) => e.toJson()).toList();
print("win2iana: $win2ianaResult");
final iana2winResult =
    ct.ianaToWindws("Asia/Hong_Kong").map((e) => e.toJson()).toList();
print('iana2win: $iana2winResult');

for more example see: tz_converter_example.dart

Donate

"Buy Me A Coffee" Alipay WechatPay

ETH BTC

License

Copyright (C) 2024 Fries_I23

win2iana_tz_converter is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

win2iana_tz_converter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with win2iana_tz_converter. If not, see <https://www.gnu.org/licenses/>.

About

A lightweight package used for converting between Windows time zones and IANA time zone database format.

Topics

Resources

License

Stars

Watchers

Forks

Languages