mirror of
https://github.com/etesync/android
synced 2025-05-12 03:48:48 +00:00
Merge pull request #473 from Springuin/master
Time zone guessing improved, fixes 'Assuming time zone Etc/GMT for Etc/G...
This commit is contained in:
commit
7d5ed0bd11
@ -341,25 +341,38 @@ public class Event extends Resource {
|
|||||||
|
|
||||||
/* guess matching Android timezone ID */
|
/* guess matching Android timezone ID */
|
||||||
protected static void validateTimeZone(DateProperty date) {
|
protected static void validateTimeZone(DateProperty date) {
|
||||||
if (date.isUtc() || !hasTime(date))
|
if (date.isUtc() || !hasTime(date))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String tzID = getTzId(date);
|
String tzID = getTzId(date);
|
||||||
if (tzID == null)
|
if (tzID == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String localTZ = Time.TIMEZONE_UTC;
|
String localTZ = Time.TIMEZONE_UTC;
|
||||||
|
boolean foundMatch = false;
|
||||||
String availableTZs[] = SimpleTimeZone.getAvailableIDs();
|
String availableTZs[] = SimpleTimeZone.getAvailableIDs();
|
||||||
for (String availableTZ : availableTZs)
|
|
||||||
if (tzID.indexOf(availableTZ, 0) != -1) {
|
// Try to find an exact match
|
||||||
localTZ = availableTZ;
|
for (String availableTZ : availableTZs) {
|
||||||
break;
|
if (tzID.equals(availableTZ)) {
|
||||||
}
|
localTZ = availableTZ;
|
||||||
|
foundMatch = true;
|
||||||
Log.d(TAG, "Assuming time zone " + localTZ + " for " + tzID);
|
break;
|
||||||
date.setTimeZone(tzRegistry.getTimeZone(localTZ));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
public static String TimezoneDefToTzId(String timezoneDef) throws IllegalArgumentException {
|
public static String TimezoneDefToTzId(String timezoneDef) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user