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

Commit b12b61a8 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Use ICU's CLDR data for "AM" and "PM" strings.

This brings DateUtils and Time in sync with bionic, icu, WebKit,
DateFormatSymbols, Formatter, and SimpleDateFormat. And specifically
means that DateUtils now knows how to say "AM" and "PM" in Japanese.

Bug: 6719054
Change-Id: Icdd75c0865505fde4115d71025eeb7515b73da4c
parent cba4d388
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

import libcore.icu.LocaleData;

/**
 * This class contains various date-related utilities for creating text for things like
 * elapsed time and date ranges, strings for days of the week and months, and AM/PM text etc.
@@ -128,10 +130,6 @@ public class DateUtils
            com.android.internal.R.string.month_shortest_november,
            com.android.internal.R.string.month_shortest_december,
        };
    private static final int[] sAmPm = new int[] {
            com.android.internal.R.string.am,
            com.android.internal.R.string.pm,
        };
    private static Configuration sLastConfig;
    private static java.text.DateFormat sStatusTimeFormat;
    private static String sElapsedFormatMMSS;
@@ -332,8 +330,7 @@ public class DateUtils
     * @return Localized version of "AM" or "PM".
     */
    public static String getAMPMString(int ampm) {
        Resources r = Resources.getSystem();
        return r.getString(sAmPm[ampm - Calendar.AM]);
        return LocaleData.get(Locale.getDefault()).amPm[ampm - Calendar.AM];
    }

    /**
+6 −2
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.content.res.Resources;
import java.util.Locale;
import java.util.TimeZone;

import libcore.icu.LocaleData;

/**
 * An alternative to the {@link java.util.Calendar} and
 * {@link java.util.GregorianCalendar} classes. An instance of the Time class represents
@@ -382,8 +384,10 @@ public class Time {
                sTimeOnlyFormat = r.getString(com.android.internal.R.string.time_of_day);
                sDateOnlyFormat = r.getString(com.android.internal.R.string.month_day_year);
                sDateTimeFormat = r.getString(com.android.internal.R.string.date_and_time);
                sAm = r.getString(com.android.internal.R.string.am);
                sPm = r.getString(com.android.internal.R.string.pm);

                LocaleData localeData = LocaleData.get(locale);
                sAm = localeData.amPm[0];
                sPm = localeData.amPm[1];

                sLocale = locale;
            }
+0 −3
Original line number Diff line number Diff line
@@ -85,9 +85,6 @@
    <string name="day_of_week_shortest_friday">6</string>
    <string name="day_of_week_shortest_saturday">7</string>

    <string name="am">vm.</string>
    <string name="pm">nm.</string>

    <string name="hour_minute_24">%-k:%M</string>
    <string name="hour_minute_ampm">%-l:%M %p</string>
    <string name="hour_minute_cap_ampm">%-l:%M %^p</string>
+0 −3
Original line number Diff line number Diff line
@@ -85,9 +85,6 @@
    <string name="day_of_week_shortest_friday"></string>
    <string name="day_of_week_shortest_saturday"></string>

    <string name="am">ጡዋት</string>
    <string name="pm">ከሳዓት</string>

    <string name="hour_minute_24">%-k:%M</string>
    <string name="hour_minute_ampm">%-l:%M %p</string>
    <string name="hour_minute_cap_ampm">%-l:%M %p</string>
+0 −2
Original line number Diff line number Diff line
@@ -85,8 +85,6 @@
    <string name="day_of_week_shortest_friday">ج</string>
    <string name="day_of_week_shortest_saturday">س</string>

    <string name="am">ص</string>
    <string name="pm">م</string>
    <string name="yesterday">أمس</string>
    <string name="today">اليوم</string>
    <string name="tomorrow">غدًا</string>
Loading