Skip to content

Commit

Permalink
Upgrade versions of dependencies. Upgrade tzdata, CLDR and UnicodeData
Browse files Browse the repository at this point in the history
  • Loading branch information
konsoletyper committed Jun 18, 2017
1 parent 40b29cd commit daa5384
Show file tree
Hide file tree
Showing 12 changed files with 7,368 additions and 135 deletions.
17 changes: 17 additions & 0 deletions .idea/runConfigurations/teavm_tz_cache.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import org.teavm.backend.javascript.spi.GeneratedBy;
import org.teavm.classlib.impl.Base46;
import org.teavm.classlib.impl.CharFlow;
import org.teavm.jso.JSBody;
import org.teavm.platform.metadata.MetadataProvider;
import org.teavm.platform.metadata.ResourceMap;

/**
*
* @author Alexey Andreev
*/
public final class DateTimeZoneProvider {
private static Map<String, DateTimeZone> cache = new HashMap<>();

Expand Down Expand Up @@ -75,7 +72,14 @@ public static String[] getIds() {
return ids.toArray(new String[ids.size()]);
}

@GeneratedBy(DateTimeZoneProviderGenerator.class)
private static native boolean timeZoneDetectionEnabled();

public static DateTimeZone detectTimezone() {
if (!timeZoneDetectionEnabled()) {
return null;
}

List<Score> zones = new ArrayList<>();
long time = System.currentTimeMillis();
int offset = -getNativeOffset(System.currentTimeMillis());
Expand Down Expand Up @@ -123,11 +127,7 @@ public static DateTimeZone detectTimezone() {
scoreTable.remove(score);
continue;
}
List<Score> prevZones = zoneMap.get(prev);
if (prevZones == null) {
prevZones = new ArrayList<>();
zoneMap.put(prev, prevZones);
}
List<Score> prevZones = zoneMap.computeIfAbsent(prev, k -> new ArrayList<>());
prevZones.add(score);
if (timeInQueue.add(prev)) {
queue.add(prev);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2017 Alexey Andreev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teavm.classlib.impl.tz;

import java.io.IOException;
import org.teavm.backend.javascript.codegen.SourceWriter;
import org.teavm.backend.javascript.spi.Generator;
import org.teavm.backend.javascript.spi.GeneratorContext;
import org.teavm.model.MethodReference;

public class DateTimeZoneProviderGenerator implements Generator {
@Override
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {
boolean autodetect = Boolean.parseBoolean(
context.getProperties().getProperty("java.util.TimeZone.autodetect", "false"));
writer.append("return " + Boolean.toString(autodetect) + ";");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.teavm.platform.metadata.ResourceMap;

public class TimeZoneGenerator implements MetadataGenerator {
public static final String TIMEZONE_DB_VERSION = "2015d";
public static final String TIMEZONE_DB_VERSION = "2017b";
public static final String TIMEZONE_DB_PATH = "org/teavm/classlib/impl/tz/tzdata" + TIMEZONE_DB_VERSION + ".zip";

public static void compile(ZoneInfoCompiler compiler, ClassLoader classLoader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.teavm.classlib.impl.tz.DateTimeZoneProvider;
import org.teavm.classlib.impl.tz.FixedDateTimeZone;
import org.teavm.classlib.impl.unicode.CLDRHelper;
import org.teavm.classlib.java.lang.TThreadInterruptHandler;

/**
* {@code TimeZone} represents a time zone offset, taking into account
Expand Down Expand Up @@ -153,8 +152,10 @@ public static String[] getAvailableIDs(int offset) {
*/
public static TTimeZone getDefault() {
if (defaultTz == null) {
//defaultTz = new TIANATimeZone(DateTimeZoneProvider.detectTimezone());
defaultTz = TTimeZone.getTimeZone("UTC");
defaultTz = new TIANATimeZone(DateTimeZoneProvider.detectTimezone());
if (defaultTz == null) {
defaultTz = TTimeZone.getTimeZone("UTC");
}
}
return (TTimeZone) defaultTz.clone();
}
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit daa5384

Please sign in to comment.