1
0
mirror of https://github.com/etesync/android synced 2025-01-22 21:51:04 +00:00

Time zone guessing improved, fixes 'Assuming time zone Etc/GMT for Etc/GMT-2'

This commit is contained in:
Marc de Hoop 2015-03-28 10:15:40 +01:00
parent 100aa665f5
commit 8d5f815be5

View File

@ -349,14 +349,27 @@ public class Event extends Resource {
return;
String localTZ = Time.TIMEZONE_UTC;
boolean foundMatch = false;
String availableTZs[] = SimpleTimeZone.getAvailableIDs();
for (String availableTZ : availableTZs)
// Try to find an exact match
for (String availableTZ : availableTZs) {
if (tzID.equals(availableTZ)) {
localTZ = availableTZ;
foundMatch = true;
break;
}
}
if (!foundMatch) {
// Try to find something else that matches
for (String availableTZ : availableTZs) {
if (tzID.indexOf(availableTZ, 0) != -1) {
localTZ = availableTZ;
break;
}
}
}
Log.d(TAG, "Assuming time zone " + localTZ + " for " + tzID);
date.setTimeZone(tzRegistry.getTimeZone(localTZ));
}