8209167: Use CLDR's time zone mappings for Windows
Reviewed-by: erikj, rriggs, ihse
This commit is contained in:
parent
85b57de9ce
commit
009cd15a1b
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))
|
||||
|
||||
################################################################################
|
||||
|
||||
ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
|
||||
ifeq ($(OPENJDK_TARGET_OS), aix)
|
||||
|
||||
TZMAPPINGS_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf
|
||||
|
||||
|
@ -37,9 +37,17 @@ CLDR_BASE_LOCALES := "en-US"
|
||||
ZONENAME_TEMPLATE := $(TOPDIR)/src/java.base/share/classes/java/time/format/ZoneName.java.template
|
||||
TZDATA_DIR := $(TOPDIR)/make/data/tzdata
|
||||
|
||||
$(CLDR_BASEMETAINFO_FILE): $(wildcard $(CLDRSRCDIR)/common/dtd/*.dtd) \
|
||||
$(wildcard $(CLDRSRCDIR)/common/main/en*.xml) \
|
||||
$(wildcard $(CLDRSRCDIR)/common/supplemental/*.xml) \
|
||||
# tzmappings generation for Windows.
|
||||
# Since the rule is shared with CLDR_BASEMETAINFO_FILE target, note that
|
||||
# just removing the target tzmappings will not recreate the tzmappings file.
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
CLDR_WINTZMAPPINGS := $(GENSRC_BASEDIR)/windows/conf/tzmappings
|
||||
$(CLDR_WINTZMAPPINGS): $(CLDR_BASEMETAINFO_FILE)
|
||||
endif
|
||||
|
||||
$(CLDR_BASEMETAINFO_FILE): $(wildcard $(CLDRSRCDIR)/dtd/*.dtd) \
|
||||
$(wildcard $(CLDRSRCDIR)/main/en*.xml) \
|
||||
$(wildcard $(CLDRSRCDIR)/supplemental/*.xml) \
|
||||
$(ZONENAME_TEMPLATE) \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(GENSRC_BASEDIR)
|
||||
@ -50,14 +58,14 @@ $(CLDR_BASEMETAINFO_FILE): $(wildcard $(CLDRSRCDIR)/common/dtd/*.dtd) \
|
||||
-zntempfile $(ZONENAME_TEMPLATE) \
|
||||
-tzdatadir $(TZDATA_DIR)
|
||||
|
||||
$(CLDR_METAINFO_FILE): $(wildcard $(CLDRSRCDIR)/common/dtd/*.dtd) \
|
||||
$(wildcard $(CLDRSRCDIR)/common/main/*.xml) \
|
||||
$(wildcard $(CLDRSRCDIR)/common/supplemental/*.xml) \
|
||||
$(CLDR_METAINFO_FILE): $(wildcard $(CLDRSRCDIR)/dtd/*.dtd) \
|
||||
$(wildcard $(CLDRSRCDIR)/main/*.xml) \
|
||||
$(wildcard $(CLDRSRCDIR)/supplemental/*.xml) \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(GENSRC_DIR)
|
||||
$(TOOL_CLDRCONVERTER) -base $(CLDRSRCDIR) \
|
||||
-baselocales $(CLDR_BASE_LOCALES) \
|
||||
-o $(GENSRC_DIR)
|
||||
|
||||
GENSRC_JAVA_BASE += $(CLDR_BASEMETAINFO_FILE)
|
||||
GENSRC_JAVA_BASE += $(CLDR_BASEMETAINFO_FILE) $(CLDR_WINTZMAPPINGS)
|
||||
GENSRC_JDK_LOCALEDATA += $(CLDR_METAINFO_FILE)
|
||||
|
@ -69,6 +69,7 @@ public class CLDRConverter {
|
||||
private static String METAZONES_SOURCE_FILE;
|
||||
private static String LIKELYSUBTAGS_SOURCE_FILE;
|
||||
private static String TIMEZONE_SOURCE_FILE;
|
||||
private static String WINZONES_SOURCE_FILE;
|
||||
static String DESTINATION_DIR = "build/gensrc";
|
||||
|
||||
static final String LOCALE_NAME_PREFIX = "locale.displayname.";
|
||||
@ -91,6 +92,7 @@ public class CLDRConverter {
|
||||
|
||||
private static SupplementDataParseHandler handlerSuppl;
|
||||
private static LikelySubtagsParseHandler handlerLikelySubtags;
|
||||
private static WinZonesParseHandler handlerWinZones;
|
||||
static SupplementalMetadataParseHandler handlerSupplMeta;
|
||||
static NumberingSystemsParseHandler handlerNumbering;
|
||||
static MetaZonesParseHandler handlerMetaZones;
|
||||
@ -241,6 +243,7 @@ public class CLDRConverter {
|
||||
METAZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/metaZones.xml";
|
||||
TIMEZONE_SOURCE_FILE = CLDR_BASE + "/bcp47/timezone.xml";
|
||||
SPPL_META_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalMetadata.xml";
|
||||
WINZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/windowsZones.xml";
|
||||
|
||||
if (BASE_LOCALES.isEmpty()) {
|
||||
setupBaseLocales("en-US");
|
||||
@ -255,9 +258,12 @@ public class CLDRConverter {
|
||||
List<Bundle> bundles = readBundleList();
|
||||
convertBundles(bundles);
|
||||
|
||||
// Generate java.time.format.ZoneName.java
|
||||
if (isBaseModule) {
|
||||
// Generate java.time.format.ZoneName.java
|
||||
generateZoneName();
|
||||
|
||||
// Generate Windows tzmappings
|
||||
generateWindowsTZMappings();
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,6 +438,10 @@ public class CLDRConverter {
|
||||
// Currently interested in deprecated time zone ids and language aliases.
|
||||
handlerSupplMeta = new SupplementalMetadataParseHandler();
|
||||
parseLDMLFile(new File(SPPL_META_SOURCE_FILE), handlerSupplMeta);
|
||||
|
||||
// Parse windowsZones
|
||||
handlerWinZones = new WinZonesParseHandler();
|
||||
parseLDMLFile(new File(WINZONES_SOURCE_FILE), handlerWinZones);
|
||||
}
|
||||
|
||||
// Parsers for data in "bcp47" directory
|
||||
@ -1088,4 +1098,42 @@ public class CLDRConverter {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate tzmappings for Windows. The format is:
|
||||
//
|
||||
// (Windows Zone Name):(REGION):(Java TZID)
|
||||
//
|
||||
// where:
|
||||
// Windows Zone Name: arbitrary time zone name string used in Windows
|
||||
// REGION: ISO3166 or UN M.49 code
|
||||
// Java TZID: Java's time zone ID
|
||||
//
|
||||
// Note: the entries are alphabetically sorted, *except* the "world" region
|
||||
// code, i.e., "001". It should be the last entry for the same windows time
|
||||
// zone name entries. (cf. TimeZone_md.c)
|
||||
private static void generateWindowsTZMappings() throws Exception {
|
||||
Files.createDirectories(Paths.get(DESTINATION_DIR, "windows", "conf"));
|
||||
Files.write(Paths.get(DESTINATION_DIR, "windows", "conf", "tzmappings"),
|
||||
handlerWinZones.keySet().stream()
|
||||
.map(k -> k + ":" + handlerWinZones.get(k) + ":")
|
||||
.sorted(new Comparator<String>() {
|
||||
public int compare(String t1, String t2) {
|
||||
String[] s1 = t1.split(":");
|
||||
String[] s2 = t2.split(":");
|
||||
if (s1[0].equals(s2[0])) {
|
||||
if (s1[1].equals("001")) {
|
||||
return 1;
|
||||
} else if (s2[1].equals("001")) {
|
||||
return -1;
|
||||
} else {
|
||||
return s1[1].compareTo(s2[1]);
|
||||
}
|
||||
} else {
|
||||
return s1[0].compareTo(s2[0]);
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()),
|
||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package build.tools.cldrconverter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Handles parsing of files in Locale Data Markup Language for
|
||||
* windowsZones.xml
|
||||
*/
|
||||
|
||||
class WinZonesParseHandler extends AbstractLDMLHandler<Object> {
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
|
||||
// avoid HTTP traffic to unicode.org
|
||||
if (systemID.startsWith(CLDRConverter.SPPL_LDML_DTD_SYSTEM_ID)) {
|
||||
return new InputSource((new File(CLDRConverter.LOCAL_SPPL_LDML_DTD)).toURI().toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
switch (qName) {
|
||||
case "mapZone":
|
||||
String zoneName = attributes.getValue("other");
|
||||
String territory = attributes.getValue("territory");
|
||||
String javatz = attributes.getValue("type").replaceFirst("\\s.*", "");
|
||||
put(zoneName + ":" + territory, javatz);
|
||||
pushIgnoredContainer(qName);
|
||||
break;
|
||||
default:
|
||||
// treat anything else as a container
|
||||
pushContainer(qName, attributes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -195,3 +195,14 @@ ifeq ($(STATIC_BUILD), true)
|
||||
|
||||
TARGETS += $(JAVA_BASE_EXPORT_SYMBOL_FILE)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Copy tzmappings file for Windows
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
$(eval $(call SetupCopyFiles, COPY_TZMAPPINGS, \
|
||||
FILES := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/windows/conf/tzmappings, \
|
||||
DEST := $(call FindLibDirForModule, $(MODULE)), \
|
||||
))
|
||||
TARGETS += $(COPY_TZMAPPINGS)
|
||||
endif
|
||||
|
@ -1,226 +0,0 @@
|
||||
#
|
||||
# This file describes mapping information between Windows and Java
|
||||
# time zones.
|
||||
# Format: Each line should include a colon separated fields of Windows
|
||||
# time zone registry key, time zone mapID, locale (which is most
|
||||
# likely used in the time zone), and Java time zone ID. Blank lines
|
||||
# and lines that start with '#' are ignored. Data lines must be sorted
|
||||
# by mapID (ASCII order).
|
||||
#
|
||||
# NOTE
|
||||
# This table format is not a public interface of any Java
|
||||
# platforms. No applications should depend on this file in any form.
|
||||
#
|
||||
# This table has been generated by a program and should not be edited
|
||||
# manually.
|
||||
#
|
||||
Romance:-1,64::Europe/Paris:
|
||||
Romance Standard Time:-1,64::Europe/Paris:
|
||||
Warsaw:-1,65::Europe/Warsaw:
|
||||
Central Europe:-1,66::Europe/Prague:
|
||||
Central Europe Standard Time:-1,66::Europe/Prague:
|
||||
Prague Bratislava:-1,66::Europe/Prague:
|
||||
W. Central Africa Standard Time:-1,66:AO:Africa/Luanda:
|
||||
FLE:-1,67:FI:Europe/Helsinki:
|
||||
FLE Standard Time:-1,67:FI:Europe/Helsinki:
|
||||
GFT:-1,67::Europe/Athens:
|
||||
GFT Standard Time:-1,67::Europe/Athens:
|
||||
GTB:-1,67::Europe/Athens:
|
||||
GTB Standard Time:-1,67::Europe/Athens:
|
||||
Israel:-1,70::Asia/Jerusalem:
|
||||
Israel Standard Time:-1,70::Asia/Jerusalem:
|
||||
Arab:-1,71::Asia/Riyadh:
|
||||
Arab Standard Time:-1,71::Asia/Riyadh:
|
||||
Arabic Standard Time:-1,71:IQ:Asia/Baghdad:
|
||||
E. Africa:-1,71:KE:Africa/Nairobi:
|
||||
E. Africa Standard Time:-1,71:KE:Africa/Nairobi:
|
||||
Saudi Arabia:-1,71::Asia/Riyadh:
|
||||
Saudi Arabia Standard Time:-1,71::Asia/Riyadh:
|
||||
Iran:-1,72::Asia/Tehran:
|
||||
Iran Standard Time:-1,72::Asia/Tehran:
|
||||
Afghanistan:-1,73::Asia/Kabul:
|
||||
Afghanistan Standard Time:-1,73::Asia/Kabul:
|
||||
India:-1,74::Asia/Calcutta:
|
||||
India Standard Time:-1,74::Asia/Calcutta:
|
||||
Myanmar Standard Time:-1,74::Asia/Rangoon:
|
||||
Nepal Standard Time:-1,74::Asia/Katmandu:
|
||||
Sri Lanka:-1,74:LK:Asia/Colombo:
|
||||
Sri Lanka Standard Time:-1,74:LK:Asia/Colombo:
|
||||
Beijing:-1,75::Asia/Shanghai:
|
||||
China:-1,75::Asia/Shanghai:
|
||||
China Standard Time:-1,75::Asia/Shanghai:
|
||||
AUS Central:-1,76::Australia/Darwin:
|
||||
AUS Central Standard Time:-1,76::Australia/Darwin:
|
||||
Cen. Australia:-1,76::Australia/Adelaide:
|
||||
Cen. Australia Standard Time:-1,76::Australia/Adelaide:
|
||||
Vladivostok:-1,77::Asia/Vladivostok:
|
||||
Vladivostok Standard Time:-1,77::Asia/Vladivostok:
|
||||
West Pacific:-1,77:GU:Pacific/Guam:
|
||||
West Pacific Standard Time:-1,77:GU:Pacific/Guam:
|
||||
E. South America:-1,80::America/Sao_Paulo:
|
||||
E. South America Standard Time:-1,80::America/Sao_Paulo:
|
||||
Greenland Standard Time:-1,80:GL:America/Godthab:
|
||||
Newfoundland:-1,81::America/St_Johns:
|
||||
Newfoundland Standard Time:-1,81::America/St_Johns:
|
||||
Pacific SA:-1,82::America/Santiago:
|
||||
Pacific SA Standard Time:-1,82::America/Santiago:
|
||||
SA Western:-1,82:BO:America/La_Paz:
|
||||
SA Western Standard Time:-1,82:BO:America/La_Paz:
|
||||
SA Pacific:-1,83::America/Bogota:
|
||||
SA Pacific Standard Time:-1,83::America/Bogota:
|
||||
US Eastern:-1,84::America/Indianapolis:
|
||||
US Eastern Standard Time:-1,84::America/Indianapolis:
|
||||
Central America Standard Time:-1,85::America/Regina:
|
||||
Mexico:-1,85::America/Mexico_City:
|
||||
Mexico Standard Time:-1,85::America/Mexico_City:
|
||||
Canada Central:-1,86::America/Regina:
|
||||
Canada Central Standard Time:-1,86::America/Regina:
|
||||
US Mountain:-1,87::America/Phoenix:
|
||||
US Mountain Standard Time:-1,87::America/Phoenix:
|
||||
GMT:0,1::Europe/London:
|
||||
GMT Standard Time:0,1::Europe/London:
|
||||
Ekaterinburg:10,11::Asia/Yekaterinburg:
|
||||
Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg:
|
||||
West Asia:10,11:UZ:Asia/Tashkent:
|
||||
West Asia Standard Time:10,11:UZ:Asia/Tashkent:
|
||||
Central Asia:12,13::Asia/Almaty:
|
||||
Central Asia Standard Time:12,13::Asia/Almaty:
|
||||
N. Central Asia Standard Time:12,13::Asia/Novosibirsk:
|
||||
Bangkok:14,15::Asia/Bangkok:
|
||||
Bangkok Standard Time:14,15::Asia/Bangkok:
|
||||
North Asia Standard Time:14,15::Asia/Krasnoyarsk:
|
||||
SE Asia:14,15::Asia/Bangkok:
|
||||
SE Asia Standard Time:14,15::Asia/Bangkok:
|
||||
North Asia East Standard Time:16,17:RU:Asia/Irkutsk:
|
||||
Singapore:16,17:SG:Asia/Singapore:
|
||||
Singapore Standard Time:16,17:SG:Asia/Singapore:
|
||||
Taipei:16,17::Asia/Taipei:
|
||||
Taipei Standard Time:16,17::Asia/Taipei:
|
||||
W. Australia:16,17:AU:Australia/Perth:
|
||||
W. Australia Standard Time:16,17:AU:Australia/Perth:
|
||||
Korea:18,19:KR:Asia/Seoul:
|
||||
Korea Standard Time:18,19:KR:Asia/Seoul:
|
||||
Tokyo:18,19::Asia/Tokyo:
|
||||
Tokyo Standard Time:18,19::Asia/Tokyo:
|
||||
Yakutsk:18,19:RU:Asia/Yakutsk:
|
||||
Yakutsk Standard Time:18,19:RU:Asia/Yakutsk:
|
||||
Central European:2,3:CS:Europe/Belgrade:
|
||||
Central European Standard Time:2,3:CS:Europe/Belgrade:
|
||||
W. Europe:2,3::Europe/Berlin:
|
||||
W. Europe Standard Time:2,3::Europe/Berlin:
|
||||
Tasmania:20,-1::Australia/Hobart:
|
||||
Tasmania Standard Time:20,-1::Australia/Hobart:
|
||||
AUS Eastern:20,21::Australia/Sydney:
|
||||
AUS Eastern Standard Time:20,21::Australia/Sydney:
|
||||
E. Australia:20,21::Australia/Brisbane:
|
||||
E. Australia Standard Time:20,21::Australia/Brisbane:
|
||||
Sydney Standard Time:20,21::Australia/Sydney:
|
||||
Tasmania Standard Time:20,65::Australia/Hobart:
|
||||
Central Pacific:22,23::Pacific/Guadalcanal:
|
||||
Central Pacific Standard Time:22,23::Pacific/Guadalcanal:
|
||||
Dateline:24,25::GMT-1200:
|
||||
Dateline Standard Time:24,25::GMT-1200:
|
||||
Fiji:24,25::Pacific/Fiji:
|
||||
Fiji Standard Time:24,25::Pacific/Fiji:
|
||||
Samoa:26,27::Pacific/Apia:
|
||||
Samoa Standard Time:26,27::Pacific/Apia:
|
||||
Hawaiian:28,29::Pacific/Honolulu:
|
||||
Hawaiian Standard Time:28,29::Pacific/Honolulu:
|
||||
Alaskan:30,31::America/Anchorage:
|
||||
Alaskan Standard Time:30,31::America/Anchorage:
|
||||
Pacific:32,33::America/Los_Angeles:
|
||||
Pacific Standard Time:32,33::America/Los_Angeles:
|
||||
Mexico Standard Time 2:34,35:MX:America/Chihuahua:
|
||||
Mountain:34,35::America/Denver:
|
||||
Mountain Standard Time:34,35::America/Denver:
|
||||
Central:36,37::America/Chicago:
|
||||
Central Standard Time:36,37::America/Chicago:
|
||||
Eastern:38,39::America/New_York:
|
||||
Eastern Standard Time:38,39::America/New_York:
|
||||
E. Europe:4,5::EET:
|
||||
E. Europe Standard Time:4,5::EET:
|
||||
Egypt:4,68::Africa/Cairo:
|
||||
Egypt Standard Time:4,68::Africa/Cairo:
|
||||
South Africa:4,69::Africa/Harare:
|
||||
South Africa Standard Time:4,69::Africa/Harare:
|
||||
Atlantic:40,41::America/Halifax:
|
||||
Atlantic Standard Time:40,41::America/Halifax:
|
||||
SA Eastern:42,43:GF:America/Cayenne:
|
||||
SA Eastern Standard Time:42,43:GF:America/Cayenne:
|
||||
Mid-Atlantic:44,45::Atlantic/South_Georgia:
|
||||
Mid-Atlantic Standard Time:44,45::Atlantic/South_Georgia:
|
||||
Azores:46,47::Atlantic/Azores:
|
||||
Azores Standard Time:46,47::Atlantic/Azores:
|
||||
Cape Verde Standard Time:46,47::Atlantic/Cape_Verde:
|
||||
Russian:6,7::Europe/Moscow:
|
||||
Russian Standard Time:6,7::Europe/Moscow:
|
||||
New Zealand:78,79::Pacific/Auckland:
|
||||
New Zealand Standard Time:78,79::Pacific/Auckland:
|
||||
Tonga Standard Time:78,79::Pacific/Tongatapu:
|
||||
Arabian:8,9::Asia/Muscat:
|
||||
Arabian Standard Time:8,9::Asia/Muscat:
|
||||
Caucasus:8,9:AM:Asia/Yerevan:
|
||||
Caucasus Standard Time:8,9:AM:Asia/Yerevan:
|
||||
GMT Standard Time:88,89::GMT:
|
||||
Greenwich:88,89::GMT:
|
||||
Greenwich Standard Time:88,89::GMT:
|
||||
Aleutian Standard Time:900,900:US:America/Adak:
|
||||
Altai Standard Time:901,901::Asia/Barnaul:
|
||||
Argentina Standard Time:902,902::America/Buenos_Aires:
|
||||
Armenian Standard Time:903,903:AM:Asia/Yerevan:
|
||||
Astrakhan Standard Time:904,904::Europe/Astrakhan:
|
||||
Aus Central W. Standard Time:905,905::Australia/Eucla:
|
||||
Azerbaijan Standard Time:906,906:AZ:Asia/Baku:
|
||||
Bahia Standard Time:907,907::America/Bahia:
|
||||
Bangladesh Standard Time:908,908::Asia/Dhaka:
|
||||
Belarus Standard Time:909,909:BY:Europe/Minsk:
|
||||
Bougainville Standard Time:910,910::Pacific/Bougainville:
|
||||
Central Brazilian Standard Time:911,911:BR:America/Cuiaba:
|
||||
Central Standard Time (Mexico):912,912::America/Mexico_City:
|
||||
Chatham Islands Standard Time:913,913::Pacific/Chatham:
|
||||
Cuba Standard Time:914,914:CU:America/Havana:
|
||||
Easter Island Standard Time:915,915:CL:Pacific/Easter:
|
||||
Eastern Standard Time (Mexico):916,916::America/Cancun:
|
||||
Georgian Standard Time:917,917:GE:Asia/Tbilisi:
|
||||
Haiti Standard Time:918,918:HT:America/Port-au-Prince:
|
||||
Jordan Standard Time:919,919:JO:Asia/Amman:
|
||||
Kaliningrad Standard Time:920,920:RU:Europe/Kaliningrad:
|
||||
Kamchatka Standard Time:921,921:RU:Asia/Kamchatka:
|
||||
Libya Standard Time:922,922:LY:Africa/Tripoli:
|
||||
Line Islands Standard Time:923,923::Pacific/Kiritimati:
|
||||
Lord Howe Standard Time:924,924::Australia/Lord_Howe:
|
||||
Magadan Standard Time:925,925::Asia/Magadan:
|
||||
Marquesas Standard Time:926,926::Pacific/Marquesas:
|
||||
Mauritius Standard Time:927,927:MU:Indian/Mauritius:
|
||||
Middle East Standard Time:928,928:LB:Asia/Beirut:
|
||||
Montevideo Standard Time:929,929:UY:America/Montevideo:
|
||||
Morocco Standard Time:930,930:MA:Africa/Casablanca:
|
||||
Mountain Standard Time (Mexico):931,931:MX:America/Chihuahua:
|
||||
Namibia Standard Time:932,932:NA:Africa/Windhoek:
|
||||
Norfolk Standard Time:933,933::Pacific/Norfolk:
|
||||
North Korea Standard Time:934,934:KP:Asia/Pyongyang:
|
||||
Pacific Standard Time (Mexico):935,935:MX:America/Tijuana:
|
||||
Pakistan Standard Time:936,936::Asia/Karachi:
|
||||
Paraguay Standard Time:937,937:PY:America/Asuncion:
|
||||
Russia Time Zone 10:938,938::Asia/Srednekolymsk:
|
||||
Russia Time Zone 11:939,939::Asia/Anadyr:
|
||||
Russia Time Zone 3:940,940::Europe/Samara:
|
||||
Saint Pierre Standard Time:941,941:PM:America/Miquelon:
|
||||
Sakhalin Standard Time:942,942::Asia/Sakhalin:
|
||||
Syria Standard Time:943,943:SY:Asia/Damascus:
|
||||
Tocantins Standard Time:944,944::America/Araguaina:
|
||||
Tomsk Standard Time:945,945::Asia/Tomsk:
|
||||
Transbaikal Standard Time:946,946::Asia/Chita:
|
||||
Turkey Standard Time:947,947::Asia/Istanbul:
|
||||
Turks And Caicos Standard Time:948,948:TC:America/Grand_Turk:
|
||||
UTC+12:949,949::GMT+1200:
|
||||
UTC-02:950,950::GMT-0200:
|
||||
UTC-08:951,951::GMT-0800:
|
||||
UTC-09:952,952::GMT-0900:
|
||||
UTC-11:953,953::GMT-1100:
|
||||
UTC:954,954::UTC:
|
||||
Ulaanbaatar Standard Time:955,955::Asia/Ulaanbaatar:
|
||||
Venezuela Standard Time:956,956::America/Caracas:
|
||||
W. Mongolia Standard Time:957,957::Asia/Hovd:
|
||||
West Bank Standard Time:958,958::Asia/Gaza:
|
||||
Western Brazilian Standard Time:959,959:BR:America/Rio_Branco:
|
@ -36,6 +36,7 @@
|
||||
|
||||
#define MAX_ZONE_CHAR 256
|
||||
#define MAX_MAPID_LENGTH 32
|
||||
#define MAX_REGION_LENGTH 4
|
||||
|
||||
#define NT_TZ_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
|
||||
#define WIN_TZ_KEY "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Time Zones"
|
||||
@ -145,7 +146,7 @@ static void customZoneName(LONG bias, char *buffer) {
|
||||
/*
|
||||
* Gets the current time zone entry in the "Time Zones" registry.
|
||||
*/
|
||||
static int getWinTimeZone(char *winZoneName, char *winMapID)
|
||||
static int getWinTimeZone(char *winZoneName)
|
||||
{
|
||||
DYNAMIC_TIME_ZONE_INFORMATION dtzi;
|
||||
DWORD timeType;
|
||||
@ -231,7 +232,6 @@ static int getWinTimeZone(char *winZoneName, char *winMapID)
|
||||
WCHAR stdNameInReg[MAX_ZONE_CHAR];
|
||||
TziValue tempTzi;
|
||||
WCHAR *stdNamePtr = tzi.StandardName;
|
||||
DWORD valueSize;
|
||||
int onlyMapID;
|
||||
|
||||
timeType = GetTimeZoneInformation(&tzi);
|
||||
@ -372,24 +372,7 @@ static int getWinTimeZone(char *winZoneName, char *winMapID)
|
||||
(void) RegCloseKey(hSubKey);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the "MapID" value of the registry to be able to eliminate
|
||||
* duplicated key names later.
|
||||
*/
|
||||
valueSize = MAX_MAPID_LENGTH;
|
||||
ret = RegQueryValueExA(hSubKey, "MapID", NULL, &valueType, winMapID, &valueSize);
|
||||
(void) RegCloseKey(hSubKey);
|
||||
(void) RegCloseKey(hKey);
|
||||
|
||||
if (ret != ERROR_SUCCESS) {
|
||||
/*
|
||||
* Vista doesn't have mapID. VALUE_UNKNOWN should be returned
|
||||
* only for Windows NT.
|
||||
*/
|
||||
if (onlyMapID == 1) {
|
||||
return VALUE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return VALUE_KEY;
|
||||
@ -410,24 +393,17 @@ static int getWinTimeZone(char *winZoneName, char *winMapID)
|
||||
* Index values for the mapping table.
|
||||
*/
|
||||
#define TZ_WIN_NAME 0
|
||||
#define TZ_MAPID 1
|
||||
#define TZ_REGION 2
|
||||
#define TZ_JAVA_NAME 3
|
||||
#define TZ_REGION 1
|
||||
#define TZ_JAVA_NAME 2
|
||||
|
||||
#define TZ_NITEMS 4 /* number of items (fields) */
|
||||
#define TZ_NITEMS 3 /* number of items (fields) */
|
||||
|
||||
/*
|
||||
* Looks up the mapping table (tzmappings) and returns a Java time
|
||||
* zone ID (e.g., "America/Los_Angeles") if found. Otherwise, NULL is
|
||||
* returned.
|
||||
*
|
||||
* value_type is one of the following values:
|
||||
* VALUE_KEY for exact key matching
|
||||
* VALUE_MAPID for MapID (this is
|
||||
* required for the old Windows, such as NT 4.0 SP3).
|
||||
*/
|
||||
static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName,
|
||||
char *mapID)
|
||||
static char *matchJavaTZ(const char *java_home_dir, char *tzName)
|
||||
{
|
||||
int line;
|
||||
int IDmatched = 0;
|
||||
@ -436,9 +412,22 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
|
||||
char *items[TZ_NITEMS];
|
||||
char *mapFileName;
|
||||
char lineBuffer[MAX_ZONE_CHAR * 4];
|
||||
int noMapID = *mapID == '\0'; /* no mapID on Vista and later */
|
||||
int offset = 0;
|
||||
const char* errorMessage = "unknown error";
|
||||
char region[MAX_REGION_LENGTH];
|
||||
|
||||
// Get the user's location
|
||||
if (GetGeoInfo(GetUserGeoID(GEOCLASS_NATION),
|
||||
GEO_ISO2, region, MAX_REGION_LENGTH, 0) == 0) {
|
||||
// If GetGeoInfo fails, fallback to LCID's country
|
||||
LCID lcid = GetUserDefaultLCID();
|
||||
if (GetLocaleInfo(lcid,
|
||||
LOCALE_SISO3166CTRYNAME, region, MAX_REGION_LENGTH) == 0 &&
|
||||
GetLocaleInfo(lcid,
|
||||
LOCALE_SISO3166CTRYNAME2, region, MAX_REGION_LENGTH) == 0) {
|
||||
region[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
mapFileName = malloc(strlen(java_home_dir) + strlen(MAPPINGS_FILE) + 1);
|
||||
if (mapFileName == NULL) {
|
||||
@ -494,28 +483,20 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
|
||||
goto illegal_format;
|
||||
}
|
||||
|
||||
if (noMapID || strcmp(mapID, items[TZ_MAPID]) == 0) {
|
||||
/*
|
||||
* We need to scan items until the
|
||||
* exact match is found or the end of data is detected.
|
||||
*/
|
||||
if (strcmp(items[TZ_WIN_NAME], tzName) == 0) {
|
||||
/*
|
||||
* When there's no mapID, we need to scan items until the
|
||||
* exact match is found or the end of data is detected.
|
||||
* Found the time zone in the mapping table.
|
||||
* Check the region code and select the appropriate entry
|
||||
*/
|
||||
if (!noMapID) {
|
||||
IDmatched = 1;
|
||||
}
|
||||
if (strcmp(items[TZ_WIN_NAME], tzName) == 0) {
|
||||
/*
|
||||
* Found the time zone in the mapping table.
|
||||
*/
|
||||
if (strcmp(items[TZ_REGION], region) == 0 ||
|
||||
strcmp(items[TZ_REGION], "001") == 0) {
|
||||
javaTZName = _strdup(items[TZ_JAVA_NAME]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (IDmatched == 1) {
|
||||
/*
|
||||
* No need to look up the mapping table further.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
@ -535,19 +516,16 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
|
||||
char *findJavaTZ_md(const char *java_home_dir)
|
||||
{
|
||||
char winZoneName[MAX_ZONE_CHAR];
|
||||
char winMapID[MAX_MAPID_LENGTH];
|
||||
char *std_timezone = NULL;
|
||||
int result;
|
||||
|
||||
winMapID[0] = 0;
|
||||
result = getWinTimeZone(winZoneName, winMapID);
|
||||
result = getWinTimeZone(winZoneName);
|
||||
|
||||
if (result != VALUE_UNKNOWN) {
|
||||
if (result == VALUE_GMTOFFSET) {
|
||||
std_timezone = _strdup(winZoneName);
|
||||
} else {
|
||||
std_timezone = matchJavaTZ(java_home_dir, result,
|
||||
winZoneName, winMapID);
|
||||
std_timezone = matchJavaTZ(java_home_dir, winZoneName);
|
||||
if (std_timezone == NULL) {
|
||||
std_timezone = getGMTOffsetID();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user