diff options
author | Eric Fischer <enf@google.com> | 2009-06-10 12:10:22 -0700 |
---|---|---|
committer | Eric Fischer <enf@google.com> | 2009-06-10 12:46:13 -0700 |
commit | 84c863d9af1270a2ccd2ccd2b8c1a753826dfe6d (patch) | |
tree | a5c0d1062e8ae70c031b4a34d572ff12f346f46b /core/java/android/text | |
parent | 295e7248b11557cf80ee9b7a12009d9cec5bd8b0 (diff) | |
download | frameworks_base-84c863d9af1270a2ccd2ccd2b8c1a753826dfe6d.zip frameworks_base-84c863d9af1270a2ccd2ccd2b8c1a753826dfe6d.tar.gz frameworks_base-84c863d9af1270a2ccd2ccd2b8c1a753826dfe6d.tar.bz2 |
Fix some 12- vs 24-hour problems in the FormatDateRange strings.
Use a resource instead of a hardcoded string for the 24-hour format
since it is not exactly the same in every locale.
Make sure the 12-hour format is actually for a 12-hour clock, even in
locales where this is not a normal thing to do. In the cap_ampm version,
do not have it try to capitalize "am" and "pm" if these are non-ASCII
strings, since strftime() doesn't know about Unicode and will mess it up.
Add a comment so that people don't think the YEAR_IN_MILLIS constant is
actually the length of any real year.
Diffstat (limited to 'core/java/android/text')
-rw-r--r-- | core/java/android/text/format/DateUtils.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/core/java/android/text/format/DateUtils.java b/core/java/android/text/format/DateUtils.java index 9073d82..bccb3a6 100644 --- a/core/java/android/text/format/DateUtils.java +++ b/core/java/android/text/format/DateUtils.java @@ -147,6 +147,9 @@ public class DateUtils public static final long HOUR_IN_MILLIS = MINUTE_IN_MILLIS * 60; public static final long DAY_IN_MILLIS = HOUR_IN_MILLIS * 24; public static final long WEEK_IN_MILLIS = DAY_IN_MILLIS * 7; + /** + * This constant is actually the length of 364 days, not of a year! + */ public static final long YEAR_IN_MILLIS = WEEK_IN_MILLIS * 52; // The following FORMAT_* symbols are used for specifying the format of @@ -176,6 +179,9 @@ public class DateUtils // Date and time format strings that are constant and don't need to be // translated. + /** + * This is not actually the preferred 24-hour date format in all locales. + */ public static final String HOUR_MINUTE_24 = "%H:%M"; public static final String MONTH_FORMAT = "%B"; public static final String ABBREV_MONTH_FORMAT = "%b"; @@ -1106,7 +1112,9 @@ public class DateUtils * * <p> * If FORMAT_CAP_AMPM is set and 12-hour time is used, then the "AM" - * and "PM" are capitalized. + * and "PM" are capitalized. You should not use this flag + * because in some locales these terms cannot be capitalized, and in + * many others it doesn't make sense to do so even though it is possible. * * <p> * If FORMAT_NO_NOON is set and 12-hour time is used, then "12pm" is @@ -1114,15 +1122,19 @@ public class DateUtils * * <p> * If FORMAT_CAP_NOON is set and 12-hour time is used, then "Noon" is - * shown instead of "noon". + * shown instead of "noon". You should probably not use this flag + * because in many locales it will not make sense to capitalize + * the term. * * <p> * If FORMAT_NO_MIDNIGHT is set and 12-hour time is used, then "12am" is * shown instead of "midnight". * * <p> - * If FORMAT_CAP_NOON is set and 12-hour time is used, then "Midnight" is - * shown instead of "midnight". + * If FORMAT_CAP_MIDNIGHT is set and 12-hour time is used, then "Midnight" + * is shown instead of "midnight". You should probably not use this + * flag because in many locales it will not make sense to capitalize + * the term. * * <p> * If FORMAT_12HOUR is set and the time is shown, then the time is @@ -1264,8 +1276,8 @@ public class DateUtils use24Hour = DateFormat.is24HourFormat(context); } if (use24Hour) { - startTimeFormat = HOUR_MINUTE_24; - endTimeFormat = HOUR_MINUTE_24; + startTimeFormat = endTimeFormat = + res.getString(com.android.internal.R.string.hour_minute_24); } else { boolean abbrevTime = (flags & (FORMAT_ABBREV_TIME | FORMAT_ABBREV_ALL)) != 0; boolean capAMPM = (flags & FORMAT_CAP_AMPM) != 0; |