Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: ash/common/system/date/date_view.cc

Issue 2740673002: Prepare Chromium and Blink for ICU 59 (Closed)
Patch Set: fix one more file in Blink; blink_tests can be built without any error on Linux Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DEPS ('k') | base/BUILD.gn » ('j') | base/i18n/unicodestring.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/date/date_view.cc
diff --git a/ash/common/system/date/date_view.cc b/ash/common/system/date/date_view.cc
index 9aa1eb51bb9ceffacd98372a96b3727d7f40a5c7..1fc3a913f970e18079a2effa8dc026fd7afa7094 100644
--- a/ash/common/system/date/date_view.cc
+++ b/ash/common/system/date/date_view.cc
@@ -57,43 +57,19 @@ bool UseMd() {
return MaterialDesignController::IsSystemTrayMenuMaterial();
}
-base::string16 FormatDateWithPattern(const base::Time& time,
- const char* pattern) {
- UErrorCode status = U_ZERO_ERROR;
- std::unique_ptr<icu::DateTimePatternGenerator> generator(
- icu::DateTimePatternGenerator::createInstance(status));
- DCHECK(U_SUCCESS(status));
- icu::UnicodeString generated_pattern =
- generator->getBestPattern(icu::UnicodeString(pattern), status);
- DCHECK(U_SUCCESS(status));
- icu::SimpleDateFormat simple_formatter(generated_pattern, status);
- DCHECK(U_SUCCESS(status));
- icu::UnicodeString date_string;
- simple_formatter.format(static_cast<UDate>(time.ToDoubleT() * 1000),
- date_string, status);
- DCHECK(U_SUCCESS(status));
- return base::string16(date_string.getBuffer(),
- static_cast<size_t>(date_string.length()));
-}
-
base::string16 FormatDate(const base::Time& time) {
if (UseMd()) {
// Use 'short' month format (e.g., "Oct") followed by non-padded day of
// month (e.g., "2", "10").
- return FormatDateWithPattern(time, "LLLd");
+ return base::i18n::TimeFormatWithPattern(time, "LLLd");
} else {
- icu::UnicodeString date_string;
- std::unique_ptr<icu::DateFormat> formatter(
- icu::DateFormat::createDateInstance(icu::DateFormat::kMedium));
- formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string);
- return base::string16(date_string.getBuffer(),
- static_cast<size_t>(date_string.length()));
+ return base::i18n::TimeFormatShortDate(time);
}
}
base::string16 FormatDayOfWeek(const base::Time& time) {
// Use 'short' day of week format (e.g., "Wed").
- return FormatDateWithPattern(time, "EEE");
+ return base::i18n::TimeFormatWithPattern(time, "EEE");
}
} // namespace
« no previous file with comments | « DEPS ('k') | base/BUILD.gn » ('j') | base/i18n/unicodestring.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698