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

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

Issue 2740673002: Prepare Chromium and Blink for ICU 59 (Closed)
Patch Set: revert accidental revert of sftnly roll during rebase 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 | « no previous file | base/BUILD.gn » ('j') | no next file with comments »
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 6a095173e72427b2f8faadc833a4b338e6511cfd..3cbd0bde397f49e45b110074e7bc1a11428c0299 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::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::TimeFormatShortDate(time);
}
}
base::string16 FormatDayOfWeek(const base::Time& time) {
// Use 'short' day of week format (e.g., "Wed").
- return FormatDateWithPattern(time, "EEE");
+ return base::TimeFormatWithPattern(time, "EEE");
}
} // namespace
« no previous file with comments | « no previous file | base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698