Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naotoj committed Sep 12, 2024
1 parent 35a94b7 commit 8784afc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 10 additions & 4 deletions make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,10 @@ private static Map<String, Object> extractZoneNames(Map<String, Object> map, Str
String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid))
.orElse(tzid);
// Follow link, if needed
var tzLink = tzdbLinks.get(tzKey);
String tzLink = null;
for (var k = tzKey; tzdbLinks.containsKey(k);) {
k = tzLink = tzdbLinks.get(k);
}
if (tzLink == null && tzdbLinks.containsValue(tzKey)) {
// reverse link search
// this is needed as in tzdb, "America/Buenos_Aires" links to
Expand Down Expand Up @@ -1213,9 +1216,11 @@ private static void generateZoneName() throws Exception {
// This method assumes handlerMetaZones is already initialized
private static Set<String> getAvailableZoneIds() {
assert handlerMetaZones != null;
assert tzdbLinks != null;
if (AVAILABLE_TZIDS == null) {
AVAILABLE_TZIDS = new HashSet<>(ZoneId.getAvailableZoneIds());
AVAILABLE_TZIDS.addAll(handlerMetaZones.keySet());
AVAILABLE_TZIDS.addAll(tzdbLinks.keySet());
AVAILABLE_TZIDS.remove(MetaZonesParseHandler.NO_METAZONE_KEY);
}

Expand Down Expand Up @@ -1492,10 +1497,11 @@ private static void fillTZDBShortNames(String tzid, String[] names) {
* If it cannot recognize the pattern, return the argument as is.
*/
private static String convertGMTName(String f) {
if (f.equals("%z")) {
// Generate GMT format at runtime
return null;
}
try {
// Should pre-fill GMT format once COMPAT is gone.
// Till then, fall back to GMT format at runtime, after COMPAT short
// names are populated
ZoneOffset.of(f);
return null;
} catch (DateTimeException dte) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ private boolean regionFormatFallback(String[] names, int index, Locale l) {
}

private String toGMTFormat(String id, boolean daylight, Locale l) {
var zr = ZoneInfoFile.getZoneInfo(id).toZoneId().getRules();
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
ResourceBundle fd = lr.getJavaTimeFormatData();
var zi = ZoneInfoFile.getZoneInfo(id);
if (zi == null) {
return fd.getString("timezone.gmtZeroFormat");
}
var zr = zi.toZoneId().getRules();
var now = Instant.now();
var saving = zr.getTransitions().reversed().stream()
.dropWhile(zot -> zot.getInstant().isAfter(now))
Expand All @@ -276,8 +282,6 @@ private String toGMTFormat(String id, boolean daylight, Locale l) {
.orElse(0);
int offset = (zr.getStandardOffset(now).getTotalSeconds() +
(daylight ? saving : 0)) / 60;
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
ResourceBundle fd = lr.getJavaTimeFormatData();

if (offset == 0) {
return fd.getString("timezone.gmtZeroFormat");
Expand Down

0 comments on commit 8784afc

Please sign in to comment.