am 4ad02d02: am a76ba7bb: am cfbc61de: Merge "Stop using getDSTSavings."

* commit '4ad02d02b8a27c627eace2bdf1fe8e0b3cfe08fb':
  Stop using getDSTSavings.
This commit is contained in:
Elliott Hughes
2012-09-06 16:41:16 -07:00
committed by Android Git Automerger

View File

@@ -337,8 +337,6 @@ public class DateTimeSettings extends SettingsPreferenceFragment
} }
} }
/* Helper routines to format timezone */
/* package */ static void setDate(int year, int month, int day) { /* package */ static void setDate(int year, int month, int day) {
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
@@ -366,45 +364,40 @@ public class DateTimeSettings extends SettingsPreferenceFragment
} }
} }
/* Helper routines to format timezone */
/* package */ static String getTimeZoneText(TimeZone tz) { /* package */ static String getTimeZoneText(TimeZone tz) {
boolean daylight = tz.inDaylightTime(new Date()); // Similar to new SimpleDateFormat("'GMT'Z, zzzz").format(new Date()), but
StringBuilder sb = new StringBuilder(); // we want "GMT-03:00" rather than "GMT-0300".
Date now = new Date();
sb.append(formatOffset(tz.getRawOffset() + return formatOffset(new StringBuilder(), tz, now).
(daylight ? tz.getDSTSavings() : 0))).
append(", "). append(", ").
append(tz.getDisplayName(daylight, TimeZone.LONG)); append(tz.getDisplayName(tz.inDaylightTime(now), TimeZone.LONG)).toString();
return sb.toString();
} }
private static char[] formatOffset(int off) { private static StringBuilder formatOffset(StringBuilder sb, TimeZone tz, Date d) {
off = off / 1000 / 60; int off = tz.getOffset(d.getTime()) / 1000 / 60;
char[] buf = new char[9];
buf[0] = 'G';
buf[1] = 'M';
buf[2] = 'T';
sb.append("GMT");
if (off < 0) { if (off < 0) {
buf[3] = '-'; sb.append('-');
off = -off; off = -off;
} else { } else {
buf[3] = '+'; sb.append('+');
} }
int hours = off / 60; int hours = off / 60;
int minutes = off % 60; int minutes = off % 60;
buf[4] = (char) ('0' + hours / 10); sb.append((char) ('0' + hours / 10));
buf[5] = (char) ('0' + hours % 10); sb.append((char) ('0' + hours % 10));
buf[6] = ':'; sb.append(':');
buf[7] = (char) ('0' + minutes / 10); sb.append((char) ('0' + minutes / 10));
buf[8] = (char) ('0' + minutes % 10); sb.append((char) ('0' + minutes % 10));
return buf; return sb;
} }
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {