Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

CountryTimezone

Delphi module provides a mapping from ISO 3166 country codes to a list of timezone names

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

CountryTimezone

CountryTimezone is a Delphi module provides a mapping from ISO 3166 country codes to a list of timezone names commonly used within that country. This allows you to easily find the relevant timezones for a given country. It uses IANA tzdb timezone descriptions from zone1970.tab.

Usage

List All Country Timezones

pascal
procedure GetAllCountryTimezones(const AList: TStrings);
var
  CountryNameDictionary: TCountryTimezoneDictionary;
  code: String;
begin
  CountryNameDictionary := TCountryTimezoneDictionary.Create();
  try
    for code in CountryNameDictionary.Keys do begin
      AList.Add(code+': '+CountryNameDictionary[code]);
    end;
  finally
    CountryNameDictionary.Free;
  end;
end;

Get Country Timezones

pascal
procedure GetCountryTimezones(const AList: TStrings);
var
  CountryNameDictionary: TCountryTimezoneDictionary;
begin
  CountryNameDictionary := TCountryTimezoneDictionary.Create();
  try
    CountryNameDictionary.GetCountryTimezones('US', AList);
  finally
    CountryNameDictionary.Free;
  end;
end;