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

Commit 6a19fdf8 authored by Neil Fuller's avatar Neil Fuller Committed by Automerger Merge Worker
Browse files

Merge "Fix missing zone strings in some cases" am: 738df114

Change-Id: I66ba5583cdd3632c6e6efb47fb1c0a0ea3b137cb
parents 7999b0a9 738df114
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;
        }
    }

}