diff --git a/src/kira_locales.rs b/src/kira_locales.rs new file mode 100644 index 0000000..107014c --- /dev/null +++ b/src/kira_locales.rs @@ -0,0 +1,253 @@ +// +// Copyright (C) <2026> + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/* + Different functions to help with localization, land locales timexone etc +*/ + +use crate::kira_system::{self, ExecCommandError}; +use regex_lite::Regex; +use std::collections::HashMap; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct LocaleData { + pub code: String, + pub charset: String, + pub description: Option, +} + +impl std::fmt::Display for LocaleData { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(descr) = &self.description { + write!(f, "{} ({})", self.code, descr) + } else { + write!(f, "{}", self.code) + } + } +} + +impl LocaleData { + pub fn default() -> Self { + Self { + code: "C.UTF-8".into(), + charset: "UTF-8".into(), + description: Some("C locale".into()), + } + } + + // creates text to be appended to locale.gen file + // in case of C locale outputs empty string + pub fn locale_gen_line(&self) -> String { + format!("{} {}", &self.code, &self.charset) + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct TimeZoneData { + pub region: String, + pub zone: String, +} + +impl TimeZoneData { + fn from_str(s: &str) -> Option { + let idx = s.find('/')?; + let (region, zone) = s.split_at(idx); + Some(Self { + region: region.into(), + zone: zone.trim_start_matches('/').into(), + }) + } + + /// + /// Returns full path to timezone file + /// Example: "/usr/share/zoneinfo/Region/City" + /// + pub fn tz_file_name(&self) -> String { + format!("/usr/share/zoneinfo/{}/{}", &self.region, &self.zone) + } +} + +impl std::fmt::Display for TimeZoneData { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}/{}", self.region, self.zone) + } +} + +const LOCALES_GEN_FILE_NAME: &str = "/etc/locale.gen"; + +/// gets locales list from system "/etc/locale.gen" file +/// Filters result by filter_charset cahrset Some("UTF-8") to get only UTF-8 locales +pub fn get_locales_blocking( + filter_charset: Option<&str>, +) -> Result, ExecCommandError> { + use std::fs::File; + use std::io::{BufReader, Read}; + + //pt_PT@euro ISO-8859-15 + //ru_UA.UTF-8 UTF-8 + //#ru_UA KOI8-U + // + // Example ru_UA.UTF-8 UTF-8 + // Groups: + // 1: code, like ru_UA.UTF-8 + // 3 charser: UTF-8 + let key_re = Regex::new(r"^[[:word:]@]+").unwrap(); + let loc_re = Regex::new(r"^#?([[:word:].@-]+) ([0-9A-Z-]+)$").unwrap(); + + let loc_desc = get_loc_descr_blocking()?; + + let mut res: Vec = Vec::new(); + let mut file_content = String::new(); + { + let locgen_file = File::open(LOCALES_GEN_FILE_NAME)?; + let mut reader = BufReader::new(locgen_file); + reader.read_to_string(&mut file_content)?; + } + for loc_line in file_content.lines() { + if let Some(captured) = loc_re.captures(loc_line.trim_end()) { + let code = captured[1].to_string(); + let charset = captured[2].to_string(); + // filters charset + if let Some(flt) = filter_charset + && charset != flt + { + continue; + } + let description = key_re + .find(&code) + .and_then(|m| loc_desc.get(m.as_str()).cloned()); + + res.push(LocaleData { + code: code, + charset: charset, + description: description, + }); + } + } + + res.push(LocaleData::default()); + + Ok(res) +} + +/// Gets locales description from "/usr/share/i18n/locales/" directory. +fn get_loc_descr_blocking() -> Result, ExecCommandError> { + // use std::process::Command; + + // /usr/share/i18n/locales/uz_UZ:title "Uzbek (latin) locale for Uzbekistan" + // /usr/share/i18n/locales/uz_UZ@cyrillic:title "Uzbek (cyrillic) locale for Uzbekistan" + // 1 group - key code + // 2 group - description + let descr_re = Regex::new(r#"^/usr/share/i18n/locales/(.+):title[[:space:]]+"(.+)"$"#).unwrap(); + + let mut res: HashMap = HashMap::new(); + + let raw_list = + kira_system::exec_command_out("grep", &vec!["-r", "title ", "/usr/share/i18n/locales/"])?; + + for descr_line in raw_list.lines() { + if let Some(captured) = descr_re.captures(descr_line.trim_end()) { + res.insert(captured[1].to_string(), captured[2].to_string()); + } + } + + Ok(res) +} + +/// Getting list of awailable timezones from system. +pub fn get_timezones_blocking() -> Result, kira_system::ExecCommandError> { + use std::path::Path; + let loc_path: &Path = Path::new("/usr/share/zoneinfo"); + + let tz_list = kira_system::ls_dir_rec(loc_path)?; + + Ok(tz_list + .iter() + .filter(|sb| sb.contains('/')) + .filter(|sb| !sb.starts_with("posix")) //filter out posix dir that contains copies + .filter_map(|str_t_zone| TimeZoneData::from_str(str_t_zone.trim())) + .collect::>()) +} + +/// +/// Function for making wild guess of locale by landguage code and timezone(if provided) +/// Ugly, needs some cleanups +/// +pub fn guess_locale( + locales: &Vec, + lang_code: &str, + maybe_tz: Option, +) -> Option { + use crate::tz_to_cc::get_cc; + // if we get lang code from wellcome stage, try to fing match with system locales + + let lang = lang_code.replace("-", "_").to_lowercase(); + + let locales_filtered: Vec = locales + .iter() + .filter(|l| l.code.to_lowercase().starts_with(&lang)) + .cloned() + .collect(); + + if locales_filtered.len() == 0 { + None + } + // return locale if ve found exactly one + else if locales_filtered.len() == 1 { + locales_filtered.first().cloned() + } + // else do search + else { + // try to use country guessed from timezone + let loc_country_guess = maybe_tz + .and_then(|tz| get_cc(&tz.region, &tz.zone)) + .and_then(|cc| { + // try to search for lang_contry in locales + let lang_search = if lang.contains('_') { + lang.clone() + } else { + format!("{}_{}", lang, cc.to_lowercase()) + }; + + locales_filtered + .iter() + .find(|l| l.code.to_lowercase().starts_with(&lang_search)) + .cloned() + }); + + // if we guessed locale by country return it + if loc_country_guess.is_some() { + loc_country_guess + // if language is en - return C locale + } else if lang == "en" { + Some(LocaleData::default()) + // else try to gess purely by language code + } else { + if lang.contains('_') { + locales_filtered + .iter() + .find(|l| l.code.to_lowercase().starts_with(&lang)) + .cloned() + } else { + let lang_search = format!("{}_{}", lang, lang); + locales_filtered + .iter() + .find(|l| l.code.to_lowercase().starts_with(&lang_search)) + .cloned() + } + } + } +} diff --git a/src/kira_system.rs b/src/kira_system.rs index 6017c8d..ffff101 100644 --- a/src/kira_system.rs +++ b/src/kira_system.rs @@ -15,7 +15,7 @@ // along with this program. If not, see . /* - Functions for creating with disk layout + Different functions for interacting with Linux system */ use crate::kira_disk_layout::*; diff --git a/src/main.rs b/src/main.rs index 3358357..3fa5f77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,7 @@ rust_i18n::i18n!("src/locales", fallback = "en"); mod kira_color_bar; mod kira_disk_layout; mod kira_include; +mod kira_locales; mod kira_logger; mod kira_scroll_list; mod kira_size; @@ -46,6 +47,7 @@ mod kira_theming; mod kira_xkb; mod stage; mod stages; +mod tz_to_cc; enum Views { Start, diff --git a/src/stages/locale/mod.rs b/src/stages/locale/mod.rs index d0cf76f..5b9c9fb 100644 --- a/src/stages/locale/mod.rs +++ b/src/stages/locale/mod.rs @@ -19,126 +19,13 @@ */ use crate::{ - kira_system::{self, ExecCommandError}, kira_theming, stage::{KiraConfig, StageAction}, }; use iced::{Alignment, widget}; -use regex_lite::Regex; use rust_i18n::t; -use std::collections::HashMap; -const LOCALES_GEN_FILE_NAME: &str = "/etc/locale.gen"; - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct LocaleData { - pub code: String, - pub charset: String, - pub description: Option, -} - -impl std::fmt::Display for LocaleData { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - if let Some(descr) = &self.description { - write!(f, "{} ({})", self.code, descr) - } else { - write!(f, "{}", self.code) - } - } -} - -impl LocaleData { - pub fn default() -> Self { - Self { - code: "C.UTF-8".into(), - charset: "UTF-8".into(), - description: Some("C locale".into()), - } - } - - // creates text to be appended to locale.gen file - // in case of C locale outputs empty string - pub fn locale_gen_line(&self) -> String { - format!("{} {}", &self.code, &self.charset) - } -} - -/// gets locales list from system "/etc/locale.gen" file -/// Filters result by filter_charset cahrset Some("UTF-8") to get only UTF-8 locales -fn get_locales_blocking(filter_charset: Option<&str>) -> Result, ExecCommandError> { - use std::fs::File; - use std::io::{BufReader, Read}; - - //pt_PT@euro ISO-8859-15 - //ru_UA.UTF-8 UTF-8 - //#ru_UA KOI8-U - // - // Example ru_UA.UTF-8 UTF-8 - // Groups: - // 1: code, like ru_UA.UTF-8 - // 3 charser: UTF-8 - let key_re = Regex::new(r"^[[:word:]@]+").unwrap(); - let loc_re = Regex::new(r"^#?([[:word:].@-]+) ([0-9A-Z-]+)$").unwrap(); - - let loc_desc = get_loc_descr_blocking()?; - - let mut res: Vec = Vec::new(); - let mut file_content = String::new(); - { - let locgen_file = File::open(LOCALES_GEN_FILE_NAME)?; - let mut reader = BufReader::new(locgen_file); - reader.read_to_string(&mut file_content)?; - } - for loc_line in file_content.lines() { - if let Some(captured) = loc_re.captures(loc_line.trim_end()) { - let code = captured[1].to_string(); - let charset = captured[2].to_string(); - // filters charset - if let Some(flt) = filter_charset - && charset != flt - { - continue; - } - let description = key_re - .find(&code) - .and_then(|m| loc_desc.get(m.as_str()).cloned()); - - res.push(LocaleData { - code: code, - charset: charset, - description: description, - }); - } - } - - res.push(LocaleData::default()); - - Ok(res) -} - -/// Gets locales description from "/usr/share/i18n/locales/" directory. -fn get_loc_descr_blocking() -> Result, ExecCommandError> { - // use std::process::Command; - - // /usr/share/i18n/locales/uz_UZ:title "Uzbek (latin) locale for Uzbekistan" - // /usr/share/i18n/locales/uz_UZ@cyrillic:title "Uzbek (cyrillic) locale for Uzbekistan" - // 1 group - key code - // 2 group - description - let descr_re = Regex::new(r#"^/usr/share/i18n/locales/(.+):title[[:space:]]+"(.+)"$"#).unwrap(); - - let mut res: HashMap = HashMap::new(); - - let raw_list = - kira_system::exec_command_out("grep", &vec!["-r", "title ", "/usr/share/i18n/locales/"])?; - - for descr_line in raw_list.lines() { - if let Some(captured) = descr_re.captures(descr_line.trim_end()) { - res.insert(captured[1].to_string(), captured[2].to_string()); - } - } - - Ok(res) -} +use crate::kira_locales::{self, LocaleData, get_locales_blocking}; #[derive(Debug, Clone)] pub struct LocaleStage { @@ -172,21 +59,16 @@ impl LocaleStage { .as_ref() .and_then(|rw| Some(rw.loc_code.clone())); + let maybe_tz = k_config + .res_timezone + .as_ref() + .and_then(|tzr| Some(tzr.time_zone.clone())); + let locales: Vec = get_locales_blocking(Some("UTF-8")).unwrap(); - // if we get lang code from wellcome stage, try to fing match with system locales - let lang_match = if let Some(lang) = maybe_lang - && lang != "en" - { - let lang = lang.replace("-", "_").to_lowercase(); - locales - .iter() - .find(|l| l.code.to_lowercase().starts_with(&lang)) - .cloned() - .unwrap_or_else(LocaleData::default) - } else { - LocaleData::default() - }; + let lang_match = maybe_lang + .and_then(|lang| kira_locales::guess_locale(&locales, &lang, maybe_tz)) + .unwrap_or_else(LocaleData::default); let lang_locale_text = format!( "{}: {}", diff --git a/src/stages/timezone/mod.rs b/src/stages/timezone/mod.rs index 7356781..e7de1d5 100644 --- a/src/stages/timezone/mod.rs +++ b/src/stages/timezone/mod.rs @@ -22,41 +22,11 @@ use crate::stage::{KiraConfig, StageAction}; use iced::{Alignment, Length, widget}; use log; use rust_i18n::t; -use std::{collections::HashMap, path::Path}; +use std::collections::HashMap; use crate::kira_scroll_list; -use crate::kira_system; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct TimeZoneData { - region: String, - zone: String, -} - -impl TimeZoneData { - fn from_str(s: &str) -> Option { - let idx = s.find('/')?; - let (region, zone) = s.split_at(idx); - Some(Self { - region: region.into(), - zone: zone.trim_start_matches('/').into(), - }) - } - - /// - /// Returns full path to timezone file - /// Example: "/usr/share/zoneinfo/Region/City" - /// - pub fn tz_file_name(&self) -> String { - format!("/usr/share/zoneinfo/{}/{}", &self.region, &self.zone) - } -} - -impl std::fmt::Display for TimeZoneData { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}/{}", self.region, self.zone) - } -} +use crate::kira_locales::{TimeZoneData, get_timezones_blocking}; #[derive(Debug, Clone)] pub struct TimeZoneStage { @@ -83,20 +53,6 @@ pub enum Message { Back, } -/// Getting list of awailable timezones from system. -fn get_timezones_blocking() -> Result, kira_system::ExecCommandError> { - let loc_path: &Path = Path::new("/usr/share/zoneinfo"); - - let tz_list = kira_system::ls_dir_rec(loc_path)?; - - Ok(tz_list - .iter() - .filter(|sb| sb.contains('/')) - .filter(|sb| !sb.starts_with("posix")) //filter out posix dir that contains copies - .filter_map(|str_t_zone| TimeZoneData::from_str(str_t_zone.trim())) - .collect::>()) -} - /// Getting list of awailable timezones from system. // fn get_timezones_blocking_depr() -> Result, String> { // use std::process::Command; diff --git a/src/tz_to_cc.rs b/src/tz_to_cc.rs new file mode 100644 index 0000000..39b8e95 --- /dev/null +++ b/src/tz_to_cc.rs @@ -0,0 +1,1167 @@ +// +// Copyright (C) <2026> + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/* + Provides exactly one function to guess country by timezone +*/ + +const TZ_TO_CC: [(&str, &[(&str, &str)]); 17] = [ + ("Arctic", &[("Longyearbyen", "SJ")]), + ( + "Europe", + &[ + ("Amsterdam", "NL"), + ("Andorra", "AD"), + ("Astrakhan", "RU"), + ("Athens", "GR"), + ("Belfast", "GB"), + ("Belgrade", "RS"), + ("Berlin", "DE"), + ("Bratislava", "SK"), + ("Brussels", "BE"), + ("Bucharest", "RO"), + ("Budapest", "HU"), + ("Busingen", "DE"), + ("Chisinau", "MD"), + ("Copenhagen", "DK"), + ("Dublin", "IE"), + ("Gibraltar", "GI"), + ("Guernsey", "GG"), + ("Helsinki", "FI"), + ("Isle_of_Man", "IM"), + ("Istanbul", "TR"), + ("Jersey", "JE"), + ("Kaliningrad", "RU"), + ("Kiev", "UA"), + ("Kirov", "RU"), + ("Kyiv", "UA"), + ("Lisbon", "PT"), + ("Ljubljana", "SI"), + ("London", "GB"), + ("Luxembourg", "LU"), + ("Madrid", "ES"), + ("Malta", "MT"), + ("Mariehamn", "AX"), + ("Minsk", "BY"), + ("Monaco", "MC"), + ("Moscow", "RU"), + ("Nicosia", "CY"), + ("Oslo", "NO"), + ("Paris", "FR"), + ("Podgorica", "ME"), + ("Prague", "CZ"), + ("Riga", "LV"), + ("Rome", "IT"), + ("Samara", "RU"), + ("San_Marino", "SM"), + ("Sarajevo", "BA"), + ("Saratov", "RU"), + ("Simferopol", "UA"), + ("Skopje", "MK"), + ("Sofia", "BG"), + ("Stockholm", "SE"), + ("Tallinn", "EE"), + ("Tirane", "AL"), + ("Tiraspol", "MD"), + ("Ulyanovsk", "RU"), + ("Uzhgorod", "UA"), + ("Vaduz", "LI"), + ("Vatican", "VA"), + ("Vienna", "AT"), + ("Vilnius", "LT"), + ("Volgograd", "RU"), + ("Warsaw", "PL"), + ("Zagreb", "HR"), + ("Zaporozhye", "UA"), + ("Zurich", "CH"), + ], + ), + ( + "Antarctica", + &[ + ("Casey", "AQ"), + ("Davis", "AQ"), + ("DumontDUrville", "AQ"), + ("Macquarie", "AU"), + ("Mawson", "AQ"), + ("McMurdo", "AQ"), + ("Palmer", "AQ"), + ("Rothera", "AQ"), + ("South_Pole", "AQ"), + ("Syowa", "AQ"), + ("Troll", "AQ"), + ("Vostok", "AQ"), + ], + ), + ("Chile", &[("Continental", "CL"), ("EasterIsland", "CL")]), + ( + "America", + &[ + ("Port_of_Spain", "TT"), + ("Rainy_River", "CA"), + ("Resolute", "CA"), + ("Argentina/Buenos_Aires", "AR"), + ("Argentina/Catamarca", "AR"), + ("Argentina/ComodRivadavia", "AR"), + ("Argentina/Cordoba", "AR"), + ("Argentina/Jujuy", "AR"), + ("Argentina/La_Rioja", "AR"), + ("Argentina/Mendoza", "AR"), + ("Argentina/Rio_Gallegos", "AR"), + ("Argentina/Salta", "AR"), + ("Argentina/San_Juan", "AR"), + ("Argentina/San_Luis", "AR"), + ("Argentina/Tucuman", "AR"), + ("Argentina/Ushuaia", "AR"), + ("Atikokan", "CA"), + ("Atka", "US"), + ("Bahia", "BR"), + ("Bahia_Banderas", "MX"), + ("Barbados", "BB"), + ("Belize", "BZ"), + ("Blanc-Sablon", "CA"), + ("Bogota", "CO"), + ("Boise", "US"), + ("Cambridge_Bay", "CA"), + ("Cancun", "MX"), + ("Caracas", "VE"), + ("Cayenne", "GF"), + ("Cayman", "KY"), + ("Chihuahua", "MX"), + ("Ciudad_Juarez", "MX"), + ("Cordoba", "AR"), + ("Costa_Rica", "CR"), + ("Creston", "CA"), + ("Cuiaba", "BR"), + ("Danmarkshavn", "GL"), + ("Dawson", "CA"), + ("Denver", "US"), + ("Detroit", "US"), + ("Edmonton", "CA"), + ("Eirunepe", "BR"), + ("Ensenada", "MX"), + ("Fort_Wayne", "US"), + ("Glace_Bay", "CA"), + ("Goose_Bay", "CA"), + ("Grenada", "GD"), + ("Guayaquil", "EC"), + ("Halifax", "CA"), + ("Hermosillo", "MX"), + ("Inuvik", "CA"), + ("Jujuy", "AR"), + ("Knox_IN", "US"), + ("La_Paz", "BO"), + ("Los_Angeles", "US"), + ("Maceio", "BR"), + ("Manaus", "BR"), + ("Martinique", "MQ"), + ("Mazatlan", "MX"), + ("Menominee", "US"), + ("Mexico_City", "MX"), + ("Moncton", "CA"), + ("Montevideo", "UY"), + ("Montserrat", "MS"), + ("Nipigon", "CA"), + ("Noronha", "BR"), + ("Panama", "PA"), + ("Phoenix", "US"), + ("Porto_Velho", "BR"), + ("Rankin_Inlet", "CA"), + ("Rio_Branco", "BR"), + ("Indiana/Indianapolis", "US"), + ("Indiana/Knox", "US"), + ("Indiana/Marengo", "US"), + ("Indiana/Petersburg", "US"), + ("Indiana/Tell_City", "US"), + ("Indiana/Vevay", "US"), + ("Indiana/Vincennes", "US"), + ("Indiana/Winamac", "US"), + ("Pangnirtung", "CA"), + ("Port-au-Prince", "HT"), + ("Puerto_Rico", "PR"), + ("Recife", "BR"), + ("Rosario", "AR"), + ("Kentucky/Louisville", "US"), + ("Kentucky/Monticello", "US"), + ("Fort_Nelson", "CA"), + ("Fortaleza", "BR"), + ("Godthab", "GL"), + ("Grand_Turk", "TC"), + ("Guatemala", "GT"), + ("Guyana", "GY"), + ("Havana", "CU"), + ("Indianapolis", "US"), + ("Jamaica", "JM"), + ("Juneau", "US"), + ("Kralendijk", "BQ"), + ("Lima", "PE"), + ("Louisville", "US"), + ("Managua", "NI"), + ("Marigot", "MF"), + ("Matamoros", "MX"), + ("Mendoza", "AR"), + ("Merida", "MX"), + ("Miquelon", "PM"), + ("Monterrey", "MX"), + ("Montreal", "CA"), + ("Nassau", "BS"), + ("Nome", "US"), + ("Nuuk", "GL"), + ("Ojinaga", "MX"), + ("Paramaribo", "SR"), + ("Porto_Acre", "BR"), + ("Punta_Arenas", "CL"), + ("Regina", "CA"), + ("North_Dakota/Beulah", "US"), + ("North_Dakota/Center", "US"), + ("North_Dakota/New_Salem", "US"), + ("Adak", "US"), + ("Anchorage", "US"), + ("Anguilla", "AI"), + ("Antigua", "AG"), + ("Araguaina", "BR"), + ("Aruba", "AW"), + ("Asuncion", "PY"), + ("Belem", "BR"), + ("Boa_Vista", "BR"), + ("Buenos_Aires", "AR"), + ("Campo_Grande", "BR"), + ("Catamarca", "AR"), + ("Chicago", "US"), + ("Coral_Harbour", "CA"), + ("Coyhaique", "CL"), + ("Curacao", "CW"), + ("Dawson_Creek", "CA"), + ("Dominica", "DM"), + ("El_Salvador", "SV"), + ("Guadeloupe", "GP"), + ("Iqaluit", "CA"), + ("Lower_Princes", "SX"), + ("Metlakatla", "US"), + ("New_York", "US"), + ("Santa_Isabel", "MX"), + ("Santarem", "BR"), + ("Santiago", "CL"), + ("Santo_Domingo", "DO"), + ("Sao_Paulo", "BR"), + ("Scoresbysund", "GL"), + ("Shiprock", "US"), + ("Sitka", "US"), + ("St_Barthelemy", "BL"), + ("St_Johns", "CA"), + ("St_Kitts", "KN"), + ("St_Lucia", "LC"), + ("St_Thomas", "VI"), + ("St_Vincent", "VC"), + ("Swift_Current", "CA"), + ("Tegucigalpa", "HN"), + ("Thule", "GL"), + ("Thunder_Bay", "CA"), + ("Tijuana", "MX"), + ("Toronto", "CA"), + ("Tortola", "VG"), + ("Vancouver", "CA"), + ("Virgin", "VI"), + ("Whitehorse", "CA"), + ("Winnipeg", "CA"), + ("Yakutat", "US"), + ("Yellowknife", "CA"), + ], + ), + ( + "Australia", + &[ + ("ACT", "AU"), + ("Adelaide", "AU"), + ("Brisbane", "AU"), + ("Broken_Hill", "AU"), + ("Canberra", "AU"), + ("Currie", "AU"), + ("Darwin", "AU"), + ("Eucla", "AU"), + ("Hobart", "AU"), + ("LHI", "AU"), + ("Lindeman", "AU"), + ("Lord_Howe", "AU"), + ("Melbourne", "AU"), + ("NSW", "AU"), + ("North", "AU"), + ("Perth", "AU"), + ("Queensland", "AU"), + ("South", "AU"), + ("Sydney", "AU"), + ("Tasmania", "AU"), + ("Victoria", "AU"), + ("West", "AU"), + ("Yancowinna", "AU"), + ], + ), + ( + "Mexico", + &[("BajaNorte", "MX"), ("BajaSur", "MX"), ("General", "MX")], + ), + ( + "Brazil", + &[ + ("Acre", "BR"), + ("DeNoronha", "BR"), + ("East", "BR"), + ("West", "BR"), + ], + ), + ( + "US", + &[ + ("Alaska", "US"), + ("Aleutian", "US"), + ("Arizona", "US"), + ("Central", "US"), + ("East-Indiana", "US"), + ("Eastern", "US"), + ("Hawaii", "US"), + ("Indiana-Starke", "US"), + ("Michigan", "US"), + ("Mountain", "US"), + ("Pacific", "US"), + ("Samoa", "AS"), + ], + ), + ( + "Indian", + &[ + ("Antananarivo", "MG"), + ("Chagos", "IO"), + ("Christmas", "CX"), + ("Cocos", "CC"), + ("Comoro", "KM"), + ("Kerguelen", "TF"), + ("Mahe", "SC"), + ("Maldives", "MV"), + ("Mauritius", "MU"), + ("Mayotte", "YT"), + ("Reunion", "RE"), + ], + ), + ( + "Pacific", + &[ + ("Apia", "WS"), + ("Auckland", "NZ"), + ("Bougainville", "PG"), + ("Chatham", "NZ"), + ("Chuuk", "FM"), + ("Easter", "CL"), + ("Efate", "VU"), + ("Enderbury", "KI"), + ("Fakaofo", "TK"), + ("Fiji", "FJ"), + ("Funafuti", "TV"), + ("Galapagos", "EC"), + ("Gambier", "PF"), + ("Guadalcanal", "SB"), + ("Guam", "GU"), + ("Honolulu", "US"), + ("Johnston", "UM"), + ("Kanton", "KI"), + ("Kiritimati", "KI"), + ("Kosrae", "FM"), + ("Kwajalein", "MH"), + ("Majuro", "MH"), + ("Marquesas", "PF"), + ("Midway", "UM"), + ("Nauru", "NR"), + ("Niue", "NU"), + ("Norfolk", "NF"), + ("Noumea", "NC"), + ("Pago_Pago", "AS"), + ("Palau", "PW"), + ("Pitcairn", "PN"), + ("Pohnpei", "FM"), + ("Ponape", "FM"), + ("Port_Moresby", "PG"), + ("Rarotonga", "CK"), + ("Saipan", "MP"), + ("Samoa", "WS"), + ("Tahiti", "PF"), + ("Tarawa", "KI"), + ("Tongatapu", "TO"), + ("Truk", "FM"), + ("Wake", "UM"), + ("Wallis", "WF"), + ("Yap", "FM"), + ], + ), + ( + "Asia", + &[ + ("Aden", "YE"), + ("Almaty", "KZ"), + ("Amman", "JO"), + ("Anadyr", "RU"), + ("Aqtau", "KZ"), + ("Aqtobe", "KZ"), + ("Ashgabat", "TM"), + ("Ashkhabad", "TM"), + ("Atyrau", "KZ"), + ("Baghdad", "IQ"), + ("Bahrain", "BH"), + ("Baku", "AZ"), + ("Bangkok", "TH"), + ("Barnaul", "RU"), + ("Beirut", "LB"), + ("Bishkek", "KG"), + ("Brunei", "BN"), + ("Calcutta", "IN"), + ("Chita", "RU"), + ("Choibalsan", "MN"), + ("Chongqing", "CN"), + ("Chungking", "CN"), + ("Colombo", "LK"), + ("Dacca", "BD"), + ("Damascus", "SY"), + ("Dhaka", "BD"), + ("Dili", "TL"), + ("Dubai", "AE"), + ("Dushanbe", "TJ"), + ("Famagusta", "CY"), + ("Gaza", "PS"), + ("Harbin", "CN"), + ("Hebron", "PS"), + ("Ho_Chi_Minh", "VN"), + ("Hong_Kong", "HK"), + ("Hovd", "MN"), + ("Irkutsk", "RU"), + ("Istanbul", "TR"), + ("Jakarta", "ID"), + ("Jayapura", "ID"), + ("Jerusalem", "IL"), + ("Kabul", "AF"), + ("Kamchatka", "RU"), + ("Karachi", "PK"), + ("Kashgar", "CN"), + ("Kathmandu", "NP"), + ("Katmandu", "NP"), + ("Khandyga", "RU"), + ("Kolkata", "IN"), + ("Krasnoyarsk", "RU"), + ("Kuala_Lumpur", "MY"), + ("Kuching", "MY"), + ("Kuwait", "KW"), + ("Macao", "MO"), + ("Macau", "MO"), + ("Magadan", "RU"), + ("Makassar", "ID"), + ("Manila", "PH"), + ("Muscat", "OM"), + ("Nicosia", "CY"), + ("Novokuznetsk", "RU"), + ("Novosibirsk", "RU"), + ("Omsk", "RU"), + ("Oral", "KZ"), + ("Phnom_Penh", "KH"), + ("Pontianak", "ID"), + ("Pyongyang", "KP"), + ("Qatar", "QA"), + ("Qostanay", "KZ"), + ("Qyzylorda", "KZ"), + ("Rangoon", "MM"), + ("Riyadh", "SA"), + ("Saigon", "VN"), + ("Sakhalin", "RU"), + ("Samarkand", "UZ"), + ("Seoul", "KR"), + ("Shanghai", "CN"), + ("Singapore", "SG"), + ("Srednekolymsk", "RU"), + ("Taipei", "TW"), + ("Tashkent", "UZ"), + ("Tbilisi", "GE"), + ("Tehran", "IR"), + ("Tel_Aviv", "IL"), + ("Thimbu", "BT"), + ("Thimphu", "BT"), + ("Tokyo", "JP"), + ("Tomsk", "RU"), + ("Ujung_Pandang", "ID"), + ("Ulaanbaatar", "MN"), + ("Ulan_Bator", "MN"), + ("Urumqi", "CN"), + ("Ust-Nera", "RU"), + ("Vientiane", "LA"), + ("Vladivostok", "RU"), + ("Yakutsk", "RU"), + ("Yangon", "MM"), + ("Yekaterinburg", "RU"), + ("Yerevan", "AM"), + ], + ), + ( + "right", + &[ + ("Africa/Abidjan", "CI"), + ("Africa/Accra", "GH"), + ("Africa/Addis_Ababa", "ET"), + ("Africa/Algiers", "DZ"), + ("Africa/Asmara", "ER"), + ("Africa/Asmera", "ER"), + ("Africa/Bamako", "ML"), + ("Africa/Bangui", "CF"), + ("Africa/Banjul", "GM"), + ("Africa/Bissau", "GW"), + ("Africa/Blantyre", "MW"), + ("Africa/Brazzaville", "CG"), + ("Africa/Bujumbura", "BI"), + ("Africa/Cairo", "EG"), + ("Africa/Casablanca", "MA"), + ("Africa/Ceuta", "ES"), + ("Africa/Conakry", "GN"), + ("Africa/Dakar", "SN"), + ("Africa/Dar_es_Salaam", "TZ"), + ("Africa/Djibouti", "DJ"), + ("Africa/Douala", "CM"), + ("Africa/El_Aaiun", "EH"), + ("Africa/Freetown", "SL"), + ("Africa/Gaborone", "BW"), + ("Africa/Harare", "ZW"), + ("Africa/Johannesburg", "ZA"), + ("Africa/Juba", "SS"), + ("Africa/Kampala", "UG"), + ("Africa/Khartoum", "SD"), + ("Africa/Kigali", "RW"), + ("Africa/Kinshasa", "CD"), + ("Africa/Lagos", "NG"), + ("Africa/Libreville", "GA"), + ("Africa/Lome", "TG"), + ("Africa/Luanda", "AO"), + ("Africa/Lubumbashi", "CD"), + ("Africa/Lusaka", "ZM"), + ("Africa/Malabo", "GQ"), + ("Africa/Maputo", "MZ"), + ("Africa/Maseru", "LS"), + ("Africa/Mbabane", "SZ"), + ("Africa/Mogadishu", "SO"), + ("Africa/Monrovia", "LR"), + ("Africa/Nairobi", "KE"), + ("Africa/Ndjamena", "TD"), + ("Africa/Niamey", "NE"), + ("Africa/Nouakchott", "MR"), + ("Africa/Ouagadougou", "BF"), + ("Africa/Porto-Novo", "BJ"), + ("Africa/Sao_Tome", "ST"), + ("Africa/Timbuktu", "ML"), + ("Africa/Tripoli", "LY"), + ("Africa/Tunis", "TN"), + ("Africa/Windhoek", "NA"), + ("America/Port_of_Spain", "TT"), + ("America/Rainy_River", "CA"), + ("America/Resolute", "CA"), + ("America/Argentina/Buenos_Aires", "AR"), + ("America/Argentina/Catamarca", "AR"), + ("America/Argentina/ComodRivadavia", "AR"), + ("America/Argentina/Cordoba", "AR"), + ("America/Argentina/Jujuy", "AR"), + ("America/Argentina/La_Rioja", "AR"), + ("America/Argentina/Mendoza", "AR"), + ("America/Argentina/Rio_Gallegos", "AR"), + ("America/Argentina/Salta", "AR"), + ("America/Argentina/San_Juan", "AR"), + ("America/Argentina/San_Luis", "AR"), + ("America/Argentina/Tucuman", "AR"), + ("America/Argentina/Ushuaia", "AR"), + ("America/Atikokan", "CA"), + ("America/Atka", "US"), + ("America/Bahia", "BR"), + ("America/Bahia_Banderas", "MX"), + ("America/Barbados", "BB"), + ("America/Belize", "BZ"), + ("America/Blanc-Sablon", "CA"), + ("America/Bogota", "CO"), + ("America/Boise", "US"), + ("America/Cambridge_Bay", "CA"), + ("America/Cancun", "MX"), + ("America/Caracas", "VE"), + ("America/Cayenne", "GF"), + ("America/Cayman", "KY"), + ("America/Chihuahua", "MX"), + ("America/Ciudad_Juarez", "MX"), + ("America/Cordoba", "AR"), + ("America/Costa_Rica", "CR"), + ("America/Creston", "CA"), + ("America/Cuiaba", "BR"), + ("America/Danmarkshavn", "GL"), + ("America/Dawson", "CA"), + ("America/Denver", "US"), + ("America/Detroit", "US"), + ("America/Edmonton", "CA"), + ("America/Eirunepe", "BR"), + ("America/Ensenada", "MX"), + ("America/Fort_Wayne", "US"), + ("America/Glace_Bay", "CA"), + ("America/Goose_Bay", "CA"), + ("America/Grenada", "GD"), + ("America/Guayaquil", "EC"), + ("America/Halifax", "CA"), + ("America/Hermosillo", "MX"), + ("America/Inuvik", "CA"), + ("America/Jujuy", "AR"), + ("America/Knox_IN", "US"), + ("America/La_Paz", "BO"), + ("America/Los_Angeles", "US"), + ("America/Maceio", "BR"), + ("America/Manaus", "BR"), + ("America/Martinique", "MQ"), + ("America/Mazatlan", "MX"), + ("America/Menominee", "US"), + ("America/Mexico_City", "MX"), + ("America/Moncton", "CA"), + ("America/Montevideo", "UY"), + ("America/Montserrat", "MS"), + ("America/Nipigon", "CA"), + ("America/Noronha", "BR"), + ("America/Panama", "PA"), + ("America/Phoenix", "US"), + ("America/Porto_Velho", "BR"), + ("America/Rankin_Inlet", "CA"), + ("America/Rio_Branco", "BR"), + ("America/Indiana/Indianapolis", "US"), + ("America/Indiana/Knox", "US"), + ("America/Indiana/Marengo", "US"), + ("America/Indiana/Petersburg", "US"), + ("America/Indiana/Tell_City", "US"), + ("America/Indiana/Vevay", "US"), + ("America/Indiana/Vincennes", "US"), + ("America/Indiana/Winamac", "US"), + ("America/Pangnirtung", "CA"), + ("America/Port-au-Prince", "HT"), + ("America/Puerto_Rico", "PR"), + ("America/Recife", "BR"), + ("America/Rosario", "AR"), + ("America/Kentucky/Louisville", "US"), + ("America/Kentucky/Monticello", "US"), + ("America/Fort_Nelson", "CA"), + ("America/Fortaleza", "BR"), + ("America/Godthab", "GL"), + ("America/Grand_Turk", "TC"), + ("America/Guatemala", "GT"), + ("America/Guyana", "GY"), + ("America/Havana", "CU"), + ("America/Indianapolis", "US"), + ("America/Jamaica", "JM"), + ("America/Juneau", "US"), + ("America/Kralendijk", "BQ"), + ("America/Lima", "PE"), + ("America/Louisville", "US"), + ("America/Managua", "NI"), + ("America/Marigot", "MF"), + ("America/Matamoros", "MX"), + ("America/Mendoza", "AR"), + ("America/Merida", "MX"), + ("America/Miquelon", "PM"), + ("America/Monterrey", "MX"), + ("America/Montreal", "CA"), + ("America/Nassau", "BS"), + ("America/Nome", "US"), + ("America/Nuuk", "GL"), + ("America/Ojinaga", "MX"), + ("America/Paramaribo", "SR"), + ("America/Porto_Acre", "BR"), + ("America/Punta_Arenas", "CL"), + ("America/Regina", "CA"), + ("America/North_Dakota/Beulah", "US"), + ("America/North_Dakota/Center", "US"), + ("America/North_Dakota/New_Salem", "US"), + ("America/Adak", "US"), + ("America/Anchorage", "US"), + ("America/Anguilla", "AI"), + ("America/Antigua", "AG"), + ("America/Araguaina", "BR"), + ("America/Aruba", "AW"), + ("America/Asuncion", "PY"), + ("America/Belem", "BR"), + ("America/Boa_Vista", "BR"), + ("America/Buenos_Aires", "AR"), + ("America/Campo_Grande", "BR"), + ("America/Catamarca", "AR"), + ("America/Chicago", "US"), + ("America/Coral_Harbour", "CA"), + ("America/Coyhaique", "CL"), + ("America/Curacao", "CW"), + ("America/Dawson_Creek", "CA"), + ("America/Dominica", "DM"), + ("America/El_Salvador", "SV"), + ("America/Guadeloupe", "GP"), + ("America/Iqaluit", "CA"), + ("America/Lower_Princes", "SX"), + ("America/Metlakatla", "US"), + ("America/New_York", "US"), + ("America/Santa_Isabel", "MX"), + ("America/Santarem", "BR"), + ("America/Santiago", "CL"), + ("America/Santo_Domingo", "DO"), + ("America/Sao_Paulo", "BR"), + ("America/Scoresbysund", "GL"), + ("America/Shiprock", "US"), + ("America/Sitka", "US"), + ("America/St_Barthelemy", "BL"), + ("America/St_Johns", "CA"), + ("America/St_Kitts", "KN"), + ("America/St_Lucia", "LC"), + ("America/St_Thomas", "VI"), + ("America/St_Vincent", "VC"), + ("America/Swift_Current", "CA"), + ("America/Tegucigalpa", "HN"), + ("America/Thule", "GL"), + ("America/Thunder_Bay", "CA"), + ("America/Tijuana", "MX"), + ("America/Toronto", "CA"), + ("America/Tortola", "VG"), + ("America/Vancouver", "CA"), + ("America/Virgin", "VI"), + ("America/Whitehorse", "CA"), + ("America/Winnipeg", "CA"), + ("America/Yakutat", "US"), + ("America/Yellowknife", "CA"), + ("Antarctica/Casey", "AQ"), + ("Antarctica/Davis", "AQ"), + ("Antarctica/DumontDUrville", "AQ"), + ("Antarctica/Macquarie", "AU"), + ("Antarctica/Mawson", "AQ"), + ("Antarctica/McMurdo", "AQ"), + ("Antarctica/Palmer", "AQ"), + ("Antarctica/Rothera", "AQ"), + ("Antarctica/South_Pole", "AQ"), + ("Antarctica/Syowa", "AQ"), + ("Antarctica/Troll", "AQ"), + ("Antarctica/Vostok", "AQ"), + ("Arctic/Longyearbyen", "SJ"), + ("Asia/Aden", "YE"), + ("Asia/Almaty", "KZ"), + ("Asia/Amman", "JO"), + ("Asia/Anadyr", "RU"), + ("Asia/Aqtau", "KZ"), + ("Asia/Aqtobe", "KZ"), + ("Asia/Ashgabat", "TM"), + ("Asia/Ashkhabad", "TM"), + ("Asia/Atyrau", "KZ"), + ("Asia/Baghdad", "IQ"), + ("Asia/Bahrain", "BH"), + ("Asia/Baku", "AZ"), + ("Asia/Bangkok", "TH"), + ("Asia/Barnaul", "RU"), + ("Asia/Beirut", "LB"), + ("Asia/Bishkek", "KG"), + ("Asia/Brunei", "BN"), + ("Asia/Calcutta", "IN"), + ("Asia/Chita", "RU"), + ("Asia/Choibalsan", "MN"), + ("Asia/Chongqing", "CN"), + ("Asia/Chungking", "CN"), + ("Asia/Colombo", "LK"), + ("Asia/Dacca", "BD"), + ("Asia/Damascus", "SY"), + ("Asia/Dhaka", "BD"), + ("Asia/Dili", "TL"), + ("Asia/Dubai", "AE"), + ("Asia/Dushanbe", "TJ"), + ("Asia/Famagusta", "CY"), + ("Asia/Gaza", "PS"), + ("Asia/Harbin", "CN"), + ("Asia/Hebron", "PS"), + ("Asia/Ho_Chi_Minh", "VN"), + ("Asia/Hong_Kong", "HK"), + ("Asia/Hovd", "MN"), + ("Asia/Irkutsk", "RU"), + ("Asia/Istanbul", "TR"), + ("Asia/Jakarta", "ID"), + ("Asia/Jayapura", "ID"), + ("Asia/Jerusalem", "IL"), + ("Asia/Kabul", "AF"), + ("Asia/Kamchatka", "RU"), + ("Asia/Karachi", "PK"), + ("Asia/Kashgar", "CN"), + ("Asia/Kathmandu", "NP"), + ("Asia/Katmandu", "NP"), + ("Asia/Khandyga", "RU"), + ("Asia/Kolkata", "IN"), + ("Asia/Krasnoyarsk", "RU"), + ("Asia/Kuala_Lumpur", "MY"), + ("Asia/Kuching", "MY"), + ("Asia/Kuwait", "KW"), + ("Asia/Macao", "MO"), + ("Asia/Macau", "MO"), + ("Asia/Magadan", "RU"), + ("Asia/Makassar", "ID"), + ("Asia/Manila", "PH"), + ("Asia/Muscat", "OM"), + ("Asia/Nicosia", "CY"), + ("Asia/Novokuznetsk", "RU"), + ("Asia/Novosibirsk", "RU"), + ("Asia/Omsk", "RU"), + ("Asia/Oral", "KZ"), + ("Asia/Phnom_Penh", "KH"), + ("Asia/Pontianak", "ID"), + ("Asia/Pyongyang", "KP"), + ("Asia/Qatar", "QA"), + ("Asia/Qostanay", "KZ"), + ("Asia/Qyzylorda", "KZ"), + ("Asia/Rangoon", "MM"), + ("Asia/Riyadh", "SA"), + ("Asia/Saigon", "VN"), + ("Asia/Sakhalin", "RU"), + ("Asia/Samarkand", "UZ"), + ("Asia/Seoul", "KR"), + ("Asia/Shanghai", "CN"), + ("Asia/Singapore", "SG"), + ("Asia/Srednekolymsk", "RU"), + ("Asia/Taipei", "TW"), + ("Asia/Tashkent", "UZ"), + ("Asia/Tbilisi", "GE"), + ("Asia/Tehran", "IR"), + ("Asia/Tel_Aviv", "IL"), + ("Asia/Thimbu", "BT"), + ("Asia/Thimphu", "BT"), + ("Asia/Tokyo", "JP"), + ("Asia/Tomsk", "RU"), + ("Asia/Ujung_Pandang", "ID"), + ("Asia/Ulaanbaatar", "MN"), + ("Asia/Ulan_Bator", "MN"), + ("Asia/Urumqi", "CN"), + ("Asia/Ust-Nera", "RU"), + ("Asia/Vientiane", "LA"), + ("Asia/Vladivostok", "RU"), + ("Asia/Yakutsk", "RU"), + ("Asia/Yangon", "MM"), + ("Asia/Yekaterinburg", "RU"), + ("Asia/Yerevan", "AM"), + ("Atlantic/Azores", "PT"), + ("Atlantic/Bermuda", "BM"), + ("Atlantic/Canary", "ES"), + ("Atlantic/Cape_Verde", "CV"), + ("Atlantic/Faeroe", "FO"), + ("Atlantic/Faroe", "FO"), + ("Atlantic/Jan_Mayen", "SJ"), + ("Atlantic/Madeira", "PT"), + ("Atlantic/Reykjavik", "IS"), + ("Atlantic/South_Georgia", "GS"), + ("Atlantic/St_Helena", "SH"), + ("Atlantic/Stanley", "FK"), + ("Australia/ACT", "AU"), + ("Australia/Adelaide", "AU"), + ("Australia/Brisbane", "AU"), + ("Australia/Broken_Hill", "AU"), + ("Australia/Canberra", "AU"), + ("Australia/Currie", "AU"), + ("Australia/Darwin", "AU"), + ("Australia/Eucla", "AU"), + ("Australia/Hobart", "AU"), + ("Australia/LHI", "AU"), + ("Australia/Lindeman", "AU"), + ("Australia/Lord_Howe", "AU"), + ("Australia/Melbourne", "AU"), + ("Australia/NSW", "AU"), + ("Australia/North", "AU"), + ("Australia/Perth", "AU"), + ("Australia/Queensland", "AU"), + ("Australia/South", "AU"), + ("Australia/Sydney", "AU"), + ("Australia/Tasmania", "AU"), + ("Australia/Victoria", "AU"), + ("Australia/West", "AU"), + ("Australia/Yancowinna", "AU"), + ("Brazil/Acre", "BR"), + ("Brazil/DeNoronha", "BR"), + ("Brazil/East", "BR"), + ("Brazil/West", "BR"), + ("Canada/Atlantic", "CA"), + ("Canada/Central", "CA"), + ("Canada/Eastern", "CA"), + ("Canada/Mountain", "CA"), + ("Canada/Newfoundland", "CA"), + ("Canada/Pacific", "CA"), + ("Canada/Saskatchewan", "CA"), + ("Canada/Yukon", "CA"), + ("Chile/Continental", "CL"), + ("Chile/EasterIsland", "CL"), + ("Etc/Greenwich", "GB"), + ("Europe/Amsterdam", "NL"), + ("Europe/Andorra", "AD"), + ("Europe/Astrakhan", "RU"), + ("Europe/Athens", "GR"), + ("Europe/Belfast", "GB"), + ("Europe/Belgrade", "RS"), + ("Europe/Berlin", "DE"), + ("Europe/Bratislava", "SK"), + ("Europe/Brussels", "BE"), + ("Europe/Bucharest", "RO"), + ("Europe/Budapest", "HU"), + ("Europe/Busingen", "DE"), + ("Europe/Chisinau", "MD"), + ("Europe/Copenhagen", "DK"), + ("Europe/Dublin", "IE"), + ("Europe/Gibraltar", "GI"), + ("Europe/Guernsey", "GG"), + ("Europe/Helsinki", "FI"), + ("Europe/Isle_of_Man", "IM"), + ("Europe/Istanbul", "TR"), + ("Europe/Jersey", "JE"), + ("Europe/Kaliningrad", "RU"), + ("Europe/Kiev", "UA"), + ("Europe/Kirov", "RU"), + ("Europe/Kyiv", "UA"), + ("Europe/Lisbon", "PT"), + ("Europe/Ljubljana", "SI"), + ("Europe/London", "GB"), + ("Europe/Luxembourg", "LU"), + ("Europe/Madrid", "ES"), + ("Europe/Malta", "MT"), + ("Europe/Mariehamn", "AX"), + ("Europe/Minsk", "BY"), + ("Europe/Monaco", "MC"), + ("Europe/Moscow", "RU"), + ("Europe/Nicosia", "CY"), + ("Europe/Oslo", "NO"), + ("Europe/Paris", "FR"), + ("Europe/Podgorica", "ME"), + ("Europe/Prague", "CZ"), + ("Europe/Riga", "LV"), + ("Europe/Rome", "IT"), + ("Europe/Samara", "RU"), + ("Europe/San_Marino", "SM"), + ("Europe/Sarajevo", "BA"), + ("Europe/Saratov", "RU"), + ("Europe/Simferopol", "UA"), + ("Europe/Skopje", "MK"), + ("Europe/Sofia", "BG"), + ("Europe/Stockholm", "SE"), + ("Europe/Tallinn", "EE"), + ("Europe/Tirane", "AL"), + ("Europe/Tiraspol", "MD"), + ("Europe/Ulyanovsk", "RU"), + ("Europe/Uzhgorod", "UA"), + ("Europe/Vaduz", "LI"), + ("Europe/Vatican", "VA"), + ("Europe/Vienna", "AT"), + ("Europe/Vilnius", "LT"), + ("Europe/Volgograd", "RU"), + ("Europe/Warsaw", "PL"), + ("Europe/Zagreb", "HR"), + ("Europe/Zaporozhye", "UA"), + ("Europe/Zurich", "CH"), + ("Indian/Antananarivo", "MG"), + ("Indian/Chagos", "IO"), + ("Indian/Christmas", "CX"), + ("Indian/Cocos", "CC"), + ("Indian/Comoro", "KM"), + ("Indian/Kerguelen", "TF"), + ("Indian/Mahe", "SC"), + ("Indian/Maldives", "MV"), + ("Indian/Mauritius", "MU"), + ("Indian/Mayotte", "YT"), + ("Indian/Reunion", "RE"), + ("Mexico/BajaNorte", "MX"), + ("Mexico/BajaSur", "MX"), + ("Mexico/General", "MX"), + ("Pacific/Apia", "WS"), + ("Pacific/Auckland", "NZ"), + ("Pacific/Bougainville", "PG"), + ("Pacific/Chatham", "NZ"), + ("Pacific/Chuuk", "FM"), + ("Pacific/Easter", "CL"), + ("Pacific/Efate", "VU"), + ("Pacific/Enderbury", "KI"), + ("Pacific/Fakaofo", "TK"), + ("Pacific/Fiji", "FJ"), + ("Pacific/Funafuti", "TV"), + ("Pacific/Galapagos", "EC"), + ("Pacific/Gambier", "PF"), + ("Pacific/Guadalcanal", "SB"), + ("Pacific/Guam", "GU"), + ("Pacific/Honolulu", "US"), + ("Pacific/Johnston", "UM"), + ("Pacific/Kanton", "KI"), + ("Pacific/Kiritimati", "KI"), + ("Pacific/Kosrae", "FM"), + ("Pacific/Kwajalein", "MH"), + ("Pacific/Majuro", "MH"), + ("Pacific/Marquesas", "PF"), + ("Pacific/Midway", "UM"), + ("Pacific/Nauru", "NR"), + ("Pacific/Niue", "NU"), + ("Pacific/Norfolk", "NF"), + ("Pacific/Noumea", "NC"), + ("Pacific/Pago_Pago", "AS"), + ("Pacific/Palau", "PW"), + ("Pacific/Pitcairn", "PN"), + ("Pacific/Pohnpei", "FM"), + ("Pacific/Ponape", "FM"), + ("Pacific/Port_Moresby", "PG"), + ("Pacific/Rarotonga", "CK"), + ("Pacific/Saipan", "MP"), + ("Pacific/Samoa", "WS"), + ("Pacific/Tahiti", "PF"), + ("Pacific/Tarawa", "KI"), + ("Pacific/Tongatapu", "TO"), + ("Pacific/Truk", "FM"), + ("Pacific/Wake", "UM"), + ("Pacific/Wallis", "WF"), + ("Pacific/Yap", "FM"), + ("US/Alaska", "US"), + ("US/Aleutian", "US"), + ("US/Arizona", "US"), + ("US/Central", "US"), + ("US/East-Indiana", "US"), + ("US/Eastern", "US"), + ("US/Hawaii", "US"), + ("US/Indiana-Starke", "US"), + ("US/Michigan", "US"), + ("US/Mountain", "US"), + ("US/Pacific", "US"), + ("US/Samoa", "AS"), + ("Cuba", "CU"), + ("Egypt", "EG"), + ("Eire", "IE"), + ("GB", "GB"), + ("GB-Eire", "GB"), + ("Greenwich", "GB"), + ("Hongkong", "HK"), + ("Iceland", "IS"), + ("Iran", "IR"), + ("Israel", "IL"), + ("Jamaica", "JM"), + ("Japan", "JP"), + ("Kwajalein", "MH"), + ("Libya", "LY"), + ("NZ", "NZ"), + ("NZ-CHAT", "NZ"), + ("Navajo", "US"), + ("PRC", "CN"), + ("Poland", "PL"), + ("Portugal", "PT"), + ("ROC", "TW"), + ("ROK", "KR"), + ("Singapore", "SG"), + ("Turkey", "TR"), + ("W-SU", "RU"), + ], + ), + ("Etc", &[("Greenwich", "UK")]), + ( + "Africa", + &[ + ("Abidjan", "CI"), + ("Accra", "GH"), + ("Addis_Ababa", "ET"), + ("Algiers", "DZ"), + ("Asmara", "ER"), + ("Asmera", "ER"), + ("Bamako", "ML"), + ("Bangui", "CF"), + ("Banjul", "GM"), + ("Bissau", "GW"), + ("Blantyre", "MW"), + ("Brazzaville", "CG"), + ("Bujumbura", "BI"), + ("Cairo", "EG"), + ("Casablanca", "MA"), + ("Ceuta", "ES"), + ("Conakry", "GN"), + ("Dakar", "SN"), + ("Dar_es_Salaam", "TZ"), + ("Djibouti", "DJ"), + ("Douala", "CM"), + ("El_Aaiun", "EH"), + ("Freetown", "SL"), + ("Gaborone", "BW"), + ("Harare", "ZW"), + ("Johannesburg", "ZA"), + ("Juba", "SS"), + ("Kampala", "UG"), + ("Khartoum", "SD"), + ("Kigali", "RW"), + ("Kinshasa", "CD"), + ("Lagos", "NG"), + ("Libreville", "GA"), + ("Lome", "TG"), + ("Luanda", "AO"), + ("Lubumbashi", "CD"), + ("Lusaka", "ZM"), + ("Malabo", "GQ"), + ("Maputo", "MZ"), + ("Maseru", "LS"), + ("Mbabane", "SZ"), + ("Mogadishu", "SO"), + ("Monrovia", "LR"), + ("Nairobi", "KE"), + ("Ndjamena", "TD"), + ("Niamey", "NE"), + ("Nouakchott", "MR"), + ("Ouagadougou", "BF"), + ("Porto-Novo", "BJ"), + ("Sao_Tome", "ST"), + ("Timbuktu", "ML"), + ("Tripoli", "LY"), + ("Tunis", "TN"), + ("Windhoek", "NA"), + ], + ), + ( + "Atlantic", + &[ + ("Azores", "PT"), + ("Bermuda", "BM"), + ("Canary", "ES"), + ("Cape_Verde", "CV"), + ("Faeroe", "FO"), + ("Faroe", "FO"), + ("Jan_Mayen", "SJ"), + ("Madeira", "PT"), + ("Reykjavik", "IS"), + ("South_Georgia", "GS"), + ("St_Helena", "SH"), + ("Stanley", "FK"), + ], + ), + ( + "Canada", + &[ + ("Atlantic", "CA"), + ("Central", "CA"), + ("Eastern", "CA"), + ("Mountain", "CA"), + ("Newfoundland", "CA"), + ("Pacific", "CA"), + ("Saskatchewan", "CA"), + ("Yukon", "CA"), + ], + ), +]; + +/// +/// Getting country code given some timezone region and timezone +/// Atlantic/South_Georgia -> get_cc(reg: "Atlantic", "South_Georgia") = GS +pub fn get_cc(reg: &str, tz: &str) -> Option { + for (r, v) in TZ_TO_CC { + if r == reg { + for (t, cc) in v { + if *t == tz { + return Some(cc.to_string()); + } + } + return None; + } + } + None +}