summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 15:08:08 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 15:08:08 +0000
commit1b6dc3e04f3438ab25faff315890bc82e82a262a (patch)
treec1528eda75d2bfa70ae68d111b65d38920085c15 /base
parentb81af210441caf958d664a7abc62050f009e464e (diff)
downloadchromium_src-1b6dc3e04f3438ab25faff315890bc82e82a262a.zip
chromium_src-1b6dc3e04f3438ab25faff315890bc82e82a262a.tar.gz
chromium_src-1b6dc3e04f3438ab25faff315890bc82e82a262a.tar.bz2
Update the time formatting APIs to use string16.
BUG=23581 TEST=everything still works Review URL: http://codereview.chromium.org/6064003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/i18n/time_formatting.cc23
-rw-r--r--base/i18n/time_formatting.h14
2 files changed, 17 insertions, 20 deletions
diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc
index 406145d..3fa984a 100644
--- a/base/i18n/time_formatting.cc
+++ b/base/i18n/time_formatting.cc
@@ -14,24 +14,21 @@ using base::Time;
namespace {
-std::wstring TimeFormat(const icu::DateFormat* formatter,
- const Time& time) {
+string16 TimeFormat(const icu::DateFormat* formatter,
+ const Time& time) {
DCHECK(formatter);
icu::UnicodeString date_string;
formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string);
- std::wstring output;
- bool success = UTF16ToWide(date_string.getBuffer(), date_string.length(),
- &output);
- DCHECK(success);
- return output;
+ return string16(date_string.getBuffer(),
+ static_cast<size_t>(date_string.length()));
}
} // namespace
namespace base {
-std::wstring TimeFormatTimeOfDay(const Time& time) {
+string16 TimeFormatTimeOfDay(const Time& time) {
// We can omit the locale parameter because the default should match
// Chrome's application locale.
scoped_ptr<icu::DateFormat> formatter(
@@ -39,31 +36,31 @@ std::wstring TimeFormatTimeOfDay(const Time& time) {
return TimeFormat(formatter.get(), time);
}
-std::wstring TimeFormatShortDate(const Time& time) {
+string16 TimeFormatShortDate(const Time& time) {
scoped_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateInstance(icu::DateFormat::kMedium));
return TimeFormat(formatter.get(), time);
}
-std::wstring TimeFormatShortDateNumeric(const Time& time) {
+string16 TimeFormatShortDateNumeric(const Time& time) {
scoped_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateInstance(icu::DateFormat::kShort));
return TimeFormat(formatter.get(), time);
}
-std::wstring TimeFormatShortDateAndTime(const Time& time) {
+string16 TimeFormatShortDateAndTime(const Time& time) {
scoped_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateTimeInstance(icu::DateFormat::kShort));
return TimeFormat(formatter.get(), time);
}
-std::wstring TimeFormatFriendlyDateAndTime(const Time& time) {
+string16 TimeFormatFriendlyDateAndTime(const Time& time) {
scoped_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateTimeInstance(icu::DateFormat::kFull));
return TimeFormat(formatter.get(), time);
}
-std::wstring TimeFormatFriendlyDate(const Time& time) {
+string16 TimeFormatFriendlyDate(const Time& time) {
scoped_ptr<icu::DateFormat> formatter(icu::DateFormat::createDateInstance(
icu::DateFormat::kFull));
return TimeFormat(formatter.get(), time);
diff --git a/base/i18n/time_formatting.h b/base/i18n/time_formatting.h
index d78ae9b..e70ad3d 100644
--- a/base/i18n/time_formatting.h
+++ b/base/i18n/time_formatting.h
@@ -9,32 +9,32 @@
#define BASE_I18N_TIME_FORMATTING_H_
#pragma once
-#include <string>
+#include "base/string16.h"
namespace base {
class Time;
// Returns the time of day, e.g., "3:07 PM".
-std::wstring TimeFormatTimeOfDay(const Time& time);
+string16 TimeFormatTimeOfDay(const Time& time);
// Returns a shortened date, e.g. "Nov 7, 2007"
-std::wstring TimeFormatShortDate(const Time& time);
+string16 TimeFormatShortDate(const Time& time);
// Returns a numeric date such as 12/13/52.
-std::wstring TimeFormatShortDateNumeric(const Time& time);
+string16 TimeFormatShortDateNumeric(const Time& time);
// Formats a time in a friendly sentence format, e.g.
// "Monday, March 6, 2008 2:44:30 PM".
-std::wstring TimeFormatShortDateAndTime(const Time& time);
+string16 TimeFormatShortDateAndTime(const Time& time);
// Formats a time in a friendly sentence format, e.g.
// "Monday, March 6, 2008 2:44:30 PM".
-std::wstring TimeFormatFriendlyDateAndTime(const Time& time);
+string16 TimeFormatFriendlyDateAndTime(const Time& time);
// Formats a time in a friendly sentence format, e.g.
// "Monday, March 6, 2008".
-std::wstring TimeFormatFriendlyDate(const Time& time);
+string16 TimeFormatFriendlyDate(const Time& time);
} // namespace base