Bug 1670227 - Manual lookup of Windows NT time zone name is unnecessary. r=Fallen

--HG--
extra : amend_source : ed306e165b3acfc835a37ed56272bc7622ed8478
This commit is contained in:
Neil Rashbrook 2020-10-09 13:05:45 +01:00
Родитель e17307c52b
Коммит ac90352318
4 изменённых файлов: 111 добавлений и 188 удалений

Просмотреть файл

@ -98,4 +98,3 @@ calendar.jar:
content/calendar-subscriptions-list.js (content/widgets/calendar-subscriptions-list.js)
content/calApplicationUtils.js (src/calApplicationUtils.js)
content/calFilter.js (src/calFilter.js)
content/WindowsNTToZoneInfoTZId.properties (src/WindowsNTToZoneInfoTZId.properties)

Просмотреть файл

@ -9,6 +9,7 @@ var EXPORTED_SYMBOLS = ["CalTimezoneService"];
var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
var { ICAL, unwrapSingle } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm");
@ -607,11 +608,7 @@ function guessSystemTimezone() {
let zoneInfoIdFromOSUserTimeZone = null;
let osUserTimeZone = null;
try {
let handler = Cc["@mozilla.org/network/protocol;1?name=http"].getService(
Ci.nsIHttpProtocolHandler
);
if (handler.oscpu.match(/^Windows/)) {
if (AppConstants.platform == "win") {
let wrk = Cc["@mozilla.org/windows-registry-key;1"].createInstance(Ci.nsIWindowsRegKey);
wrk.open(
wrk.ROOT_KEY_LOCAL_MACHINE,
@ -619,49 +616,11 @@ function guessSystemTimezone() {
wrk.ACCESS_READ
);
if (wrk.hasValue("TimeZoneKeyName")) {
// Windows Vista and later have this key.
// Clear trailing garbage on this key, see bug 1129712.
osUserTimeZone = wrk.readStringValue("TimeZoneKeyName").split("\0")[0];
} else {
// If on Windows XP, current timezone only lists its localized name,
// so to find its registry key name, match localized name to
// localized names of each windows timezone listed in registry.
// Then use the registry key name to see if this timezone has a
// known ZoneInfo name.
let currentTZStandardName = wrk.readStringValue("StandardName");
wrk.close();
wrk.open(
wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
wrk.ACCESS_READ
);
// Linear search matching localized name of standard timezone
// to find the non-localized registry key.
// (Registry keys are sorted by subkeyName, not by localized name
// nor offset, so cannot use binary search.)
for (let i = 0; i < wrk.childCount; i++) {
let subkeyName = wrk.getChildName(i);
let subkey = wrk.openChild(subkeyName, wrk.ACCESS_READ);
let std = subkey.readStringValue("Std");
subkey.close();
if (std == currentTZStandardName) {
osUserTimeZone = subkeyName;
break;
}
}
zoneInfoIdFromOSUserTimeZone = osUserTimeZone;
}
wrk.close();
if (osUserTimeZone != null) {
// Lookup timezone registry key in table of known tz keys
// to convert to ZoneInfo timezone id.
const regKeyToZoneInfoBundle = Services.strings.createBundle(
"chrome://calendar/content/WindowsNTToZoneInfoTZId.properties"
);
zoneInfoIdFromOSUserTimeZone = regKeyToZoneInfoBundle.GetStringFromName(osUserTimeZone);
}
} else {
// Else look for ZoneInfo timezone id in
// - TZ environment variable value

Просмотреть файл

@ -1,143 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Mapping
# from: Microsoft Windows NT/2K/XP/Vista registry timezone subkey (not localized name)
# to: ZoneInfo timezone identifier (Eggert & Olson)
#
Afghanistan Standard Time: Asia/Kabul
Alaskan Standard Time: America/Anchorage
Aleutian Standard Time: America/Adak
Altai Standard Time: Asia/Barnaul
Arab Standard Time: Asia/Riyadh
Arabian Standard Time: Asia/Dubai
Arabic Standard Time: Asia/Baghdad
Argentina Standard Time: America/Buenos_Aires
Armenian Standard Time: Asia/Yerevan
Astrakhan Standard Time: Europe/Astrakhan
Atlantic Standard Time: America/Halifax
AUS Central Standard Time: Australia/Darwin
Aus Central W. Standard Time: Australia/Eucla
AUS Eastern Standard Time: Australia/Sydney
Azerbaijan Standard Time: Asia/Baku
Azores Standard Time: Atlantic/Azores
Bahia Standard Time: America/Bahia
Bangkok Standard Time: Asia/Bangkok
Bangladesh Standard Time: Asia/Dhaka
Belarus Standard Time: Europe/Minsk
Bougainville Standard Time: Pacific/Bougainville
Canada Central Standard Time: America/Regina
Cape Verde Standard Time: Atlantic/Cape_Verde
Caucasus Standard Time: Asia/Yerevan
Cen. Australia Standard Time: Australia/Adelaide
Central America Standard Time: America/Guatemala
Central Asia Standard Time: Asia/Almaty
Central Brazilian Standard Time: America/Cuiaba
Central Europe Standard Time: Europe/Prague
Central European Standard Time: Europe/Warsaw
Central Pacific Standard Time: Pacific/Guadalcanal
Central Standard Time (Mexico): America/Mexico_City
Central Standard Time: America/Chicago
Chatham Islands Standard Time: Pacific/Chatham
China Standard Time: Asia/Shanghai
Cuba Standard Time: America/Havana
E. Africa Standard Time: Africa/Nairobi
E. Australia Standard Time: Australia/Brisbane
E. Europe Standard Time: Europe/Chisinau
E. South America Standard Time: America/Sao_Paulo
Easter Island Standard Time: Pacific/Easter
Eastern Standard Time (Mexico): America/Cancun
Eastern Standard Time: America/New_York
Egypt Standard Time: Africa/Cairo
Ekaterinburg Standard Time: Asia/Yekaterinburg
Fiji Standard Time: Pacific/Fiji
FLE Standard Time: Europe/Helsinki
Georgian Standard Time: Asia/Tbilisi
GFT Standard Time: Europe/Athens
GMT Standard Time: Europe/London
Greenland Standard Time: America/Godthab
Greenwich Standard Time: Atlantic/Reykjavik
GTB Standard Time: Europe/Athens
Haiti Standard Time: America/Port-au-Prince
Hawaiian Standard Time: Pacific/Honolulu
India Standard Time: Asia/Calcutta
Iran Standard Time: Asia/Tehran
Israel Standard Time: Asia/Jerusalem
Jordan Standard Time: Asia/Amman
Kaliningrad Standard Time: Europe/Kaliningrad
Korea Standard Time: Asia/Seoul
Libya Standard Time: Africa/Tripoli
Line Islands Standard Time: Pacific/Kiritimati
Lord Howe Standard Time: Australia/Lord_Howe
Magadan Standard Time: Asia/Magadan
Magallanes Standard Time: America/Punta_Arenas
Marquesas Standard Time: Pacific/Marquesas
Mauritius Standard Time: Indian/Mauritius
Mexico Standard Time: America/Mexico_City
Mid-Atlantic Standard Time: Atlantic/South_Georgia
Middle East Standard Time: Asia/Beirut
Montevideo Standard Time: America/Montevideo
Morocco Standard Time: Africa/Casablanca
Mountain Standard Time (Mexico): America/Chihuahua
Mountain Standard Time: America/Denver
Myanmar Standard Time: Asia/Rangoon
N. Central Asia Standard Time: Asia/Novosibirsk
Namibia Standard Time: Africa/Windhoek
Nepal Standard Time: Asia/Katmandu
New Zealand Standard Time: Pacific/Auckland
Newfoundland Standard Time: America/St_Johns
Norfolk Standard Time: Pacific/Norfolk
North Asia East Standard Time: Asia/Irkutsk
North Asia Standard Time: Asia/Krasnoyarsk
North Korea Standard Time: Asia/Pyongyang
Omsk Standard Time: Asia/Omsk
Pacific SA Standard Time: America/Santiago
Pacific Standard Time (Mexico): America/Tijuana
Pacific Standard Time: America/Los_Angeles
Pakistan Standard Time: Asia/Karachi
Paraguay Standard Time: America/Asuncion
Romance Standard Time: Europe/Paris
Russia Time Zone 10: Asia/Srednekolymsk
Russia Time Zone 11: Asia/Kamchatka
Russia Time Zone 3: Europe/Samara
Russian Standard Time: Europe/Moscow
SA Eastern Standard Time: America/Cayenne
SA Pacific Standard Time: America/Bogota
SA Western Standard Time: America/La_Paz
Saint Pierre Standard Time: America/Miquelon
Sakhalin Standard Time: Asia/Sakhalin
Samoa Standard Time: Pacific/Apia
Sao Tome Standard Time: Africa/Sao_Tome
Saratov Standard Time: Europe/Saratov
Saudi Arabia Standard Time: Asia/Riyadh
SE Asia Standard Time: Asia/Bangkok
Singapore Standard Time: Asia/Singapore
South Africa Standard Time: Africa/Johannesburg
Sri Lanka Standard Time: Asia/Colombo
Sudan Standard Time: Africa/Khartoum
Sydney Standard Time: Australia/Sydney
Syria Standard Time: Asia/Damascus
Taipei Standard Time: Asia/Taipei
Tasmania Standard Time: Australia/Hobart
Tocantins Standard Time: America/Araguaina
Tokyo Standard Time: Asia/Tokyo
Tomsk Standard Time: Asia/Tomsk
Tonga Standard Time: Pacific/Tongatapu
Transbaikal Standard Time: Asia/Chita
Turkey Standard Time: Europe/Istanbul
Turks And Caicos Standard Time: America/Grand_Turk
Ulaanbaatar Standard Time: Asia/Ulaanbaatar
US Eastern Standard Time: America/Indiana/Indianapolis
US Mountain Standard Time: America/Phoenix
Venezuela Standard Time: America/Caracas
Vladivostok Standard Time: Asia/Vladivostok
W. Australia Standard Time: Australia/Perth
W. Central Africa Standard Time: Africa/Lagos
W. Europe Standard Time: Europe/Berlin
W. Mongolia Standard Time: Asia/Hovd
West Asia Standard Time: Asia/Tashkent
West Bank Standard Time: Asia/Hebron
West Pacific Standard Time: Pacific/Port_Moresby
Western Brazilian Standard Time: America/Rio_Branco
Yakutsk Standard Time: Asia/Yakutsk

Просмотреть файл

@ -19,6 +19,12 @@
"Alaskan Standard Time": {
"aliasTo": "America/Anchorage"
},
"Aleutian Standard Time": {
"aliasTo": "America/Adak"
},
"Altai Standard Time": {
"aliasTo": "Asia/Barnaul"
},
"America/Argentina/ComodRivadavia": {
"aliasTo": "America/Argentina/Catamarca"
},
@ -49,6 +55,12 @@
"Argentina Standard Time": {
"aliasTo": "America/Argentina/Buenos_Aires"
},
"Armenian Standard Time": {
"aliasTo": "Asia/Yerevan"
},
"Astrakhan Standard Time": {
"aliasTo": "Europe/Astrakhan"
},
"Asia/Calcutta": {
"aliasTo": "Asia/Kolkata"
},
@ -70,6 +82,9 @@
"Atlantic/Jan_Mayen": {
"aliasTo": "Europe/Oslo"
},
"Aus Central W. Standard Time": {
"aliasTo": "Australia/Eucla"
},
"Azerbaijan Standard Time": {
"aliasTo": "Asia/Baku"
},
@ -82,9 +97,15 @@
"Bangladesh Standard Time": {
"aliasTo": "Asia/Dhaka"
},
"Bangkok Standard Time": {
"aliasTo": "Asia/Bangkok"
},
"Belarus Standard Time": {
"aliasTo": "Europe/Minsk"
},
"Bougainville Standard Time": {
"aliasTo": "Pacific/Bougainville"
},
"Canada Central Standard Time": {
"aliasTo": "America/Regina"
},
@ -121,21 +142,36 @@
"Central Standard Time (Mexico)": {
"aliasTo": "America/Mexico_City"
},
"Chatham Islands Standard Time": {
"aliasTo": "Pacific/Chatham"
},
"China Standard Time": {
"aliasTo": "Asia/Shanghai"
},
"Cuba Standard Time": {
"aliasTo": "America/Havana"
},
"E. Africa Standard Time": {
"aliasTo": "Africa/Nairobi"
},
"E. Australia Standard Time": {
"aliasTo": "Australia/Brisbane"
},
"E. Europe Standard Time": {
"aliasTo": "Europe/Chisinau"
},
"E. South America Standard Time": {
"aliasTo": "America/Sao_Paulo"
},
"Easter Island Standard Time": {
"aliasTo": "Pacific/Easter"
},
"Eastern Standard Time": {
"aliasTo": "America/New_York"
},
"Eastern Standard Time (Mexico)": {
"aliasTo": "America/Cancun"
},
"Egypt Standard Time": {
"aliasTo": "Africa/Cairo"
},
@ -169,6 +205,9 @@
"Fiji Standard Time": {
"aliasTo": "Pacific/Fiji"
},
"GFT Standard Time": {
"aliasTo": "Europe/Athens"
},
"GMT": {
"aliasTo": "UTC"
},
@ -196,6 +235,9 @@
"Greenwich Standard Time": {
"aliasTo": "Atlantic/Reykjavik"
},
"Haiti Standard Time": {
"aliasTo": "America/Port-au-Prince"
},
"Hawaiian Standard Time": {
"aliasTo": "Pacific/Honolulu"
},
@ -223,12 +265,27 @@
"Line Islands Standard Time": {
"aliasTo": "Pacific/Kiritimati"
},
"Lord Howe Standard Time": {
"aliasTo": "Australia/Lord_Howe"
},
"Magadan Standard Time": {
"aliasTo": "Asia/Magadan"
},
"Magallanes Standard Time": {
"aliasTo": "America/Punta_Arenas"
},
"Marquesas Standard Time": {
"aliasTo": "Pacific/Marquesas"
},
"Mauritius Standard Time": {
"aliasTo": "Indian/Mauritius"
},
"Mexico Standard Time": {
"aliasTo": "America/Mexico_City"
},
"Mid-Atlantic Standard Time": {
"aliasTo": "Atlantic/South_Georgia"
},
"Middle East Standard Time": {
"aliasTo": "Asia/Beirut"
},
@ -262,12 +319,21 @@
"Newfoundland Standard Time": {
"aliasTo": "America/St_Johns"
},
"Norfolk Standard Time": {
"aliasTo": "Pacific/Norfolk"
},
"North Asia East Standard Time": {
"aliasTo": "Asia/Irkutsk"
},
"North Asia Standard Time": {
"aliasTo": "Asia/Krasnoyarsk"
},
"North Korea Standard Time": {
"aliasTo": "Asia/Pyongyang"
},
"Omsk Standard Time": {
"aliasTo": "Asia/Omsk"
},
"Pacific SA Standard Time": {
"aliasTo": "America/Santiago"
},
@ -313,9 +379,24 @@
"SE Asia Standard Time": {
"aliasTo": "Asia/Bangkok"
},
"Saint Pierre Standard Time": {
"aliasTo": "America/Miquelon"
},
"Sakhalin Standard Time": {
"aliasTo": "Asia/Sakhalin"
},
"Samoa Standard Time": {
"aliasTo": "Pacific/Apia"
},
"Sao Tome Standard Time": {
"aliasTo": "Africa/Sao_Tome"
},
"Saratov Standard Time": {
"aliasTo": "Europe/Saratov"
},
"Saudi Arabia Standard Time": {
"aliasTo": "Asia/Riyadh"
},
"Singapore Standard Time": {
"aliasTo": "Asia/Singapore"
},
@ -325,6 +406,12 @@
"Sri Lanka Standard Time": {
"aliasTo": "Asia/Colombo"
},
"Sudan Standard Time": {
"aliasTo": "Africa/Khartoum"
},
"Sydney Standard Time": {
"aliasTo": "Australia/Sydney"
},
"Syria Standard Time": {
"aliasTo": "Asia/Damascus"
},
@ -334,15 +421,27 @@
"Tasmania Standard Time": {
"aliasTo": "Australia/Hobart"
},
"Tocantins Standard Time": {
"aliasTo": "America/Araguaina"
},
"Tokyo Standard Time": {
"aliasTo": "Asia/Tokyo"
},
"Tomsk Standard Time": {
"aliasTo": "Asia/Tomsk"
},
"Tonga Standard Time": {
"aliasTo": "Pacific/Tongatapu"
},
"Transbaikal Standard Time": {
"aliasTo": "Asia/Chita"
},
"Turkey Standard Time": {
"aliasTo": "Europe/Istanbul"
},
"Turks And Caicos Standard Time": {
"aliasTo": "America/Grand_Turk"
},
"UCT": {
"aliasTo": "UTC"
},
@ -388,12 +487,21 @@
"W. Europe Standard Time": {
"aliasTo": "Europe/Berlin"
},
"W. Mongolia Standard Time": {
"aliasTo": "Asia/Hovd"
},
"West Asia Standard Time": {
"aliasTo": "Asia/Tashkent"
},
"West Bank Standard Time": {
"aliasTo": "Asia/Hebron"
},
"West Pacific Standard Time": {
"aliasTo": "Pacific/Port_Moresby"
},
"Western Brazilian Standard Time": {
"aliasTo": "America/Rio_Branco"
},
"Yakutsk Standard Time": {
"aliasTo": "Asia/Yakutsk"
},