Skip to content

Commit

Permalink
Bugfix: zone country is detected incorrect if link is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ellenaua committed Feb 20, 2020
1 parent aea92e2 commit 21172fc
Show file tree
Hide file tree
Showing 20 changed files with 2,635 additions and 677 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = function(grunt) {
grunt.initConfig({
nodeunit : {
zones : [
"tests/zones/**/*.js"
"tests/zones/**/*.js",
"tests/countries/*.js"
],
core : [
"tests/moment-timezone/*.js"
Expand Down
179 changes: 94 additions & 85 deletions builds/moment-timezone-with-data-10-year-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
zone = zones[name] = new Zone();
zone._set(link);
zone.name = names[name];
zone.countries = zone._getCountries()
zone.countries = zone._getCountries();
return zone;
}

Expand All @@ -458,6 +458,10 @@
return out.sort();
}

function getCountryNames () {
return Object.keys(countries);
}

function addLink (aliases) {
var i, alias, normal0, normal1;

Expand Down Expand Up @@ -509,17 +513,21 @@
return null;
}

function zonesForCountry(country) {
function zonesForCountry(country, with_offset) {
country = getCountry(country);

if (country) {
return country.zones.map(function (zone_name) {
var zone = getZone(zone_name);
return {
name: zone_name,
offset: zone.offset(new Date())
}
});
if (with_offset) {
return country.zones.map(function (zone_name) {
var zone = getZone(zone_name);
return {
name: zone_name,
offset: zone.utcOffset(new Date())
};
});
} else {
return country.zones;
}
}

return null;
Expand Down Expand Up @@ -589,6 +597,7 @@
tz.needsOffset = needsOffset;
tz.moveInvalidForward = true;
tz.moveAmbiguousForward = false;
tz.countries = getCountryNames;
tz.zonesForCountry = zonesForCountry;

/************************************
Expand Down Expand Up @@ -1292,49 +1301,49 @@
"AD|Europe/Andorra",
"AE|Asia/Dubai",
"AF|Asia/Kabul",
"AG|America/Port_of_Spain",
"AI|America/Port_of_Spain",
"AG|America/Port_of_Spain America/Antigua",
"AI|America/Port_of_Spain America/Anguilla",
"AL|Europe/Tirane",
"AM|Asia/Yerevan",
"AO|Africa/Lagos",
"AQ|Antarctica/Casey Antarctica/Davis Antarctica/DumontDUrville Antarctica/Mawson Antarctica/Palmer Antarctica/Rothera Antarctica/Syowa Antarctica/Troll Antarctica/Vostok Pacific/Auckland",
"AO|Africa/Lagos Africa/Luanda",
"AQ|Antarctica/Casey Antarctica/Davis Antarctica/DumontDUrville Antarctica/Mawson Antarctica/Palmer Antarctica/Rothera Antarctica/Syowa Antarctica/Troll Antarctica/Vostok Pacific/Auckland Antarctica/McMurdo",
"AR|America/Argentina/Buenos_Aires America/Argentina/Cordoba America/Argentina/Salta America/Argentina/Jujuy America/Argentina/Tucuman America/Argentina/Catamarca America/Argentina/La_Rioja America/Argentina/San_Juan America/Argentina/Mendoza America/Argentina/San_Luis America/Argentina/Rio_Gallegos America/Argentina/Ushuaia",
"AS|Pacific/Pago_Pago",
"AT|Europe/Vienna",
"AU|Australia/Lord_Howe Antarctica/Macquarie Australia/Hobart Australia/Currie Australia/Melbourne Australia/Sydney Australia/Broken_Hill Australia/Brisbane Australia/Lindeman Australia/Adelaide Australia/Darwin Australia/Perth Australia/Eucla",
"AW|America/Curacao",
"AX|Europe/Helsinki",
"AW|America/Curacao America/Aruba",
"AX|Europe/Helsinki Europe/Mariehamn",
"AZ|Asia/Baku",
"BA|Europe/Belgrade",
"BA|Europe/Belgrade Europe/Sarajevo",
"BB|America/Barbados",
"BD|Asia/Dhaka",
"BE|Europe/Brussels",
"BF|Africa/Abidjan",
"BF|Africa/Abidjan Africa/Ouagadougou",
"BG|Europe/Sofia",
"BH|Asia/Qatar",
"BI|Africa/Maputo",
"BJ|Africa/Lagos",
"BL|America/Port_of_Spain",
"BH|Asia/Qatar Asia/Bahrain",
"BI|Africa/Maputo Africa/Bujumbura",
"BJ|Africa/Lagos Africa/Porto-Novo",
"BL|America/Port_of_Spain America/St_Barthelemy",
"BM|Atlantic/Bermuda",
"BN|Asia/Brunei",
"BO|America/La_Paz",
"BQ|America/Curacao",
"BQ|America/Curacao America/Kralendijk",
"BR|America/Noronha America/Belem America/Fortaleza America/Recife America/Araguaina America/Maceio America/Bahia America/Sao_Paulo America/Campo_Grande America/Cuiaba America/Santarem America/Porto_Velho America/Boa_Vista America/Manaus America/Eirunepe America/Rio_Branco",
"BS|America/Nassau",
"BT|Asia/Thimphu",
"BW|Africa/Maputo",
"BW|Africa/Maputo Africa/Gaborone",
"BY|Europe/Minsk",
"BZ|America/Belize",
"CA|America/St_Johns America/Halifax America/Glace_Bay America/Moncton America/Goose_Bay America/Blanc-Sablon America/Toronto America/Nipigon America/Thunder_Bay America/Iqaluit America/Pangnirtung America/Atikokan America/Winnipeg America/Rainy_River America/Resolute America/Rankin_Inlet America/Regina America/Swift_Current America/Edmonton America/Cambridge_Bay America/Yellowknife America/Inuvik America/Creston America/Dawson_Creek America/Fort_Nelson America/Vancouver America/Whitehorse America/Dawson",
"CC|Indian/Cocos",
"CD|Africa/Maputo Africa/Lagos",
"CF|Africa/Lagos",
"CG|Africa/Lagos",
"CD|Africa/Maputo Africa/Lagos Africa/Kinshasa Africa/Lubumbashi",
"CF|Africa/Lagos Africa/Bangui",
"CG|Africa/Lagos Africa/Brazzaville",
"CH|Europe/Zurich",
"CI|Africa/Abidjan",
"CK|Pacific/Rarotonga",
"CL|America/Santiago America/Punta_Arenas Pacific/Easter",
"CM|Africa/Lagos",
"CM|Africa/Lagos Africa/Douala",
"CN|Asia/Shanghai Asia/Urumqi",
"CO|America/Bogota",
"CR|America/Costa_Rica",
Expand All @@ -1344,38 +1353,38 @@
"CX|Indian/Christmas",
"CY|Asia/Nicosia Asia/Famagusta",
"CZ|Europe/Prague",
"DE|Europe/Zurich Europe/Berlin",
"DJ|Africa/Nairobi",
"DE|Europe/Zurich Europe/Berlin Europe/Busingen",
"DJ|Africa/Nairobi Africa/Djibouti",
"DK|Europe/Copenhagen",
"DM|America/Port_of_Spain",
"DM|America/Port_of_Spain America/Dominica",
"DO|America/Santo_Domingo",
"DZ|Africa/Algiers",
"EC|America/Guayaquil Pacific/Galapagos",
"EE|Europe/Tallinn",
"EG|Africa/Cairo",
"EH|Africa/El_Aaiun",
"ER|Africa/Nairobi",
"ER|Africa/Nairobi Africa/Asmara",
"ES|Europe/Madrid Africa/Ceuta Atlantic/Canary",
"ET|Africa/Nairobi",
"ET|Africa/Nairobi Africa/Addis_Ababa",
"FI|Europe/Helsinki",
"FJ|Pacific/Fiji",
"FK|Atlantic/Stanley",
"FM|Pacific/Chuuk Pacific/Pohnpei Pacific/Kosrae",
"FO|Atlantic/Faroe",
"FR|Europe/Paris",
"GA|Africa/Lagos",
"GA|Africa/Lagos Africa/Libreville",
"GB|Europe/London",
"GD|America/Port_of_Spain",
"GD|America/Port_of_Spain America/Grenada",
"GE|Asia/Tbilisi",
"GF|America/Cayenne",
"GG|Europe/London",
"GG|Europe/London Europe/Guernsey",
"GH|Africa/Accra",
"GI|Europe/Gibraltar",
"GL|America/Godthab America/Danmarkshavn America/Scoresbysund America/Thule",
"GM|Africa/Abidjan",
"GN|Africa/Abidjan",
"GP|America/Port_of_Spain",
"GQ|Africa/Lagos",
"GM|Africa/Abidjan Africa/Banjul",
"GN|Africa/Abidjan Africa/Conakry",
"GP|America/Port_of_Spain America/Guadeloupe",
"GQ|Africa/Lagos Africa/Malabo",
"GR|Europe/Athens",
"GS|Atlantic/South_Georgia",
"GT|America/Guatemala",
Expand All @@ -1384,71 +1393,71 @@
"GY|America/Guyana",
"HK|Asia/Hong_Kong",
"HN|America/Tegucigalpa",
"HR|Europe/Belgrade",
"HR|Europe/Belgrade Europe/Zagreb",
"HT|America/Port-au-Prince",
"HU|Europe/Budapest",
"ID|Asia/Jakarta Asia/Pontianak Asia/Makassar Asia/Jayapura",
"IE|Europe/Dublin",
"IL|Asia/Jerusalem",
"IM|Europe/London",
"IM|Europe/London Europe/Isle_of_Man",
"IN|Asia/Kolkata",
"IO|Indian/Chagos",
"IQ|Asia/Baghdad",
"IR|Asia/Tehran",
"IS|Atlantic/Reykjavik",
"IT|Europe/Rome",
"JE|Europe/London",
"JE|Europe/London Europe/Jersey",
"JM|America/Jamaica",
"JO|Asia/Amman",
"JP|Asia/Tokyo",
"KE|Africa/Nairobi",
"KG|Asia/Bishkek",
"KH|Asia/Bangkok",
"KH|Asia/Bangkok Asia/Phnom_Penh",
"KI|Pacific/Tarawa Pacific/Enderbury Pacific/Kiritimati",
"KM|Africa/Nairobi",
"KN|America/Port_of_Spain",
"KM|Africa/Nairobi Indian/Comoro",
"KN|America/Port_of_Spain America/St_Kitts",
"KP|Asia/Pyongyang",
"KR|Asia/Seoul",
"KW|Asia/Riyadh",
"KY|America/Panama",
"KW|Asia/Riyadh Asia/Kuwait",
"KY|America/Panama America/Cayman",
"KZ|Asia/Almaty Asia/Qyzylorda Asia/Qostanay Asia/Aqtobe Asia/Aqtau Asia/Atyrau Asia/Oral",
"LA|Asia/Bangkok",
"LA|Asia/Bangkok Asia/Vientiane",
"LB|Asia/Beirut",
"LC|America/Port_of_Spain",
"LI|Europe/Zurich",
"LC|America/Port_of_Spain America/St_Lucia",
"LI|Europe/Zurich Europe/Vaduz",
"LK|Asia/Colombo",
"LR|Africa/Monrovia",
"LS|Africa/Johannesburg",
"LS|Africa/Johannesburg Africa/Maseru",
"LT|Europe/Vilnius",
"LU|Europe/Luxembourg",
"LV|Europe/Riga",
"LY|Africa/Tripoli",
"MA|Africa/Casablanca",
"MC|Europe/Monaco",
"MD|Europe/Chisinau",
"ME|Europe/Belgrade",
"MF|America/Port_of_Spain",
"MG|Africa/Nairobi",
"ME|Europe/Belgrade Europe/Podgorica",
"MF|America/Port_of_Spain America/Marigot",
"MG|Africa/Nairobi Indian/Antananarivo",
"MH|Pacific/Majuro Pacific/Kwajalein",
"MK|Europe/Belgrade",
"ML|Africa/Abidjan",
"MK|Europe/Belgrade Europe/Skopje",
"ML|Africa/Abidjan Africa/Bamako",
"MM|Asia/Yangon",
"MN|Asia/Ulaanbaatar Asia/Hovd Asia/Choibalsan",
"MO|Asia/Macau",
"MP|Pacific/Guam",
"MP|Pacific/Guam Pacific/Saipan",
"MQ|America/Martinique",
"MR|Africa/Abidjan",
"MS|America/Port_of_Spain",
"MR|Africa/Abidjan Africa/Nouakchott",
"MS|America/Port_of_Spain America/Montserrat",
"MT|Europe/Malta",
"MU|Indian/Mauritius",
"MV|Indian/Maldives",
"MW|Africa/Maputo",
"MW|Africa/Maputo Africa/Blantyre",
"MX|America/Mexico_City America/Cancun America/Merida America/Monterrey America/Matamoros America/Mazatlan America/Chihuahua America/Ojinaga America/Hermosillo America/Tijuana America/Bahia_Banderas",
"MY|Asia/Kuala_Lumpur Asia/Kuching",
"MZ|Africa/Maputo",
"NA|Africa/Windhoek",
"NC|Pacific/Noumea",
"NE|Africa/Lagos",
"NE|Africa/Lagos Africa/Niamey",
"NF|Pacific/Norfolk",
"NG|Africa/Lagos",
"NI|America/Managua",
Expand All @@ -1458,7 +1467,7 @@
"NR|Pacific/Nauru",
"NU|Pacific/Niue",
"NZ|Pacific/Auckland Pacific/Chatham",
"OM|Asia/Dubai",
"OM|Asia/Dubai Asia/Muscat",
"PA|America/Panama",
"PE|America/Lima",
"PF|Pacific/Tahiti Pacific/Marquesas Pacific/Gambier",
Expand All @@ -1478,32 +1487,32 @@
"RO|Europe/Bucharest",
"RS|Europe/Belgrade",
"RU|Europe/Kaliningrad Europe/Moscow Europe/Simferopol Europe/Kirov Europe/Astrakhan Europe/Volgograd Europe/Saratov Europe/Ulyanovsk Europe/Samara Asia/Yekaterinburg Asia/Omsk Asia/Novosibirsk Asia/Barnaul Asia/Tomsk Asia/Novokuznetsk Asia/Krasnoyarsk Asia/Irkutsk Asia/Chita Asia/Yakutsk Asia/Khandyga Asia/Vladivostok Asia/Ust-Nera Asia/Magadan Asia/Sakhalin Asia/Srednekolymsk Asia/Kamchatka Asia/Anadyr",
"RW|Africa/Maputo",
"RW|Africa/Maputo Africa/Kigali",
"SA|Asia/Riyadh",
"SB|Pacific/Guadalcanal",
"SC|Indian/Mahe",
"SD|Africa/Khartoum",
"SE|Europe/Stockholm",
"SG|Asia/Singapore",
"SH|Africa/Abidjan",
"SI|Europe/Belgrade",
"SJ|Europe/Oslo",
"SK|Europe/Prague",
"SL|Africa/Abidjan",
"SM|Europe/Rome",
"SN|Africa/Abidjan",
"SO|Africa/Nairobi",
"SH|Africa/Abidjan Atlantic/St_Helena",
"SI|Europe/Belgrade Europe/Ljubljana",
"SJ|Europe/Oslo Arctic/Longyearbyen",
"SK|Europe/Prague Europe/Bratislava",
"SL|Africa/Abidjan Africa/Freetown",
"SM|Europe/Rome Europe/San_Marino",
"SN|Africa/Abidjan Africa/Dakar",
"SO|Africa/Nairobi Africa/Mogadishu",
"SR|America/Paramaribo",
"SS|Africa/Juba",
"ST|Africa/Sao_Tome",
"SV|America/El_Salvador",
"SX|America/Curacao",
"SX|America/Curacao America/Lower_Princes",
"SY|Asia/Damascus",
"SZ|Africa/Johannesburg",
"SZ|Africa/Johannesburg Africa/Mbabane",
"TC|America/Grand_Turk",
"TD|Africa/Ndjamena",
"TF|Indian/Reunion Indian/Kerguelen",
"TG|Africa/Abidjan",
"TG|Africa/Abidjan Africa/Lome",
"TH|Asia/Bangkok",
"TJ|Asia/Dushanbe",
"TK|Pacific/Fakaofo",
Expand All @@ -1515,27 +1524,27 @@
"TT|America/Port_of_Spain",
"TV|Pacific/Funafuti",
"TW|Asia/Taipei",
"TZ|Africa/Nairobi",
"TZ|Africa/Nairobi Africa/Dar_es_Salaam",
"UA|Europe/Simferopol Europe/Kiev Europe/Uzhgorod Europe/Zaporozhye",
"UG|Africa/Nairobi",
"UM|Pacific/Pago_Pago Pacific/Wake Pacific/Honolulu",
"UG|Africa/Nairobi Africa/Kampala",
"UM|Pacific/Pago_Pago Pacific/Wake Pacific/Honolulu Pacific/Midway",
"US|America/New_York America/Detroit America/Kentucky/Louisville America/Kentucky/Monticello America/Indiana/Indianapolis America/Indiana/Vincennes America/Indiana/Winamac America/Indiana/Marengo America/Indiana/Petersburg America/Indiana/Vevay America/Chicago America/Indiana/Tell_City America/Indiana/Knox America/Menominee America/North_Dakota/Center America/North_Dakota/New_Salem America/North_Dakota/Beulah America/Denver America/Boise America/Phoenix America/Los_Angeles America/Anchorage America/Juneau America/Sitka America/Metlakatla America/Yakutat America/Nome America/Adak Pacific/Honolulu",
"UY|America/Montevideo",
"UZ|Asia/Samarkand Asia/Tashkent",
"VA|Europe/Rome",
"VC|America/Port_of_Spain",
"VA|Europe/Rome Europe/Vatican",
"VC|America/Port_of_Spain America/St_Vincent",
"VE|America/Caracas",
"VG|America/Port_of_Spain",
"VI|America/Port_of_Spain",
"VG|America/Port_of_Spain America/Tortola",
"VI|America/Port_of_Spain America/St_Thomas",
"VN|Asia/Bangkok Asia/Ho_Chi_Minh",
"VU|Pacific/Efate",
"WF|Pacific/Wallis",
"WS|Pacific/Apia",
"YE|Asia/Riyadh",
"YT|Africa/Nairobi",
"YE|Asia/Riyadh Asia/Aden",
"YT|Africa/Nairobi Indian/Mayotte",
"ZA|Africa/Johannesburg",
"ZM|Africa/Maputo",
"ZW|Africa/Maputo"
"ZM|Africa/Maputo Africa/Lusaka",
"ZW|Africa/Maputo Africa/Harare"
]
});

Expand Down
2 changes: 1 addition & 1 deletion builds/moment-timezone-with-data-10-year-range.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 21172fc

Please sign in to comment.