Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 738df114 authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Fix missing zone strings in some cases"

parents 0d4010c5 eafec7a2
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -149,22 +149,31 @@ public class TimeZoneInfo {
         * @return TimeZoneInfo containing time zone names, exemplar locations and GMT offset
         */
        public TimeZoneInfo format(TimeZone timeZone) {
            final String id = timeZone.getID();
            String canonicalZoneId = getCanonicalZoneId(timeZone);
            final TimeZoneNames timeZoneNames = mTimeZoneFormat.getTimeZoneNames();
            final java.util.TimeZone javaTimeZone = java.util.TimeZone.getTimeZone(id);
            final java.util.TimeZone javaTimeZone = java.util.TimeZone.getTimeZone(canonicalZoneId);
            final CharSequence gmtOffset = ZoneGetter.getGmtOffsetText(mTimeZoneFormat, mLocale,
                javaTimeZone, mNow);
            return new TimeZoneInfo.Builder(timeZone)
                    .setGenericName(timeZoneNames.getDisplayName(id,
                    .setGenericName(timeZoneNames.getDisplayName(canonicalZoneId,
                            TimeZoneNames.NameType.LONG_GENERIC, mNow.getTime()))
                    .setStandardName(timeZoneNames.getDisplayName(id,
                    .setStandardName(timeZoneNames.getDisplayName(canonicalZoneId,
                            TimeZoneNames.NameType.LONG_STANDARD, mNow.getTime()))
                    .setDaylightName(timeZoneNames.getDisplayName(id,
                    .setDaylightName(timeZoneNames.getDisplayName(canonicalZoneId,
                            TimeZoneNames.NameType.LONG_DAYLIGHT, mNow.getTime()))
                    .setExemplarLocation(timeZoneNames.getExemplarLocationName(id))
                    .setExemplarLocation(timeZoneNames.getExemplarLocationName(canonicalZoneId))
                    .setGmtOffset(gmtOffset)
                    .build();
        }

        private static String getCanonicalZoneId(TimeZone timeZone) {
            final String id = timeZone.getID();
            final String canonicalId = TimeZone.getCanonicalID(id);
            if (canonicalId != null) {
                return canonicalId;
            }
            return id;
        }
    }

}