diff options
Diffstat (limited to 'chrome/common/time_format.cc')
-rw-r--r-- | chrome/common/time_format.cc | 68 |
1 files changed, 2 insertions, 66 deletions
diff --git a/chrome/common/time_format.cc b/chrome/common/time_format.cc index 1c4b576..e97316c 100644 --- a/chrome/common/time_format.cc +++ b/chrome/common/time_format.cc @@ -36,6 +36,7 @@ #include "base/singleton.h" #include "base/string_util.h" #include "base/time.h" +#include "base/time_format.h" #include "chrome/common/l10n_util.h" #include "chrome/common/stl_util-inl.h" #include "generated_resources.h" @@ -45,28 +46,6 @@ #include "unicode/plurrule.h" #include "unicode/smpdtfmt.h" -namespace { - -UDate TimeToUDate(const Time& time) { - return static_cast<UDate>(time.ToDoubleT() * 1000); -} - -std::wstring FormatTime(const DateFormat* formatter, const Time& time) { - DCHECK(formatter); - UnicodeString date_string; - formatter->format(TimeToUDate(time), date_string); - std::wstring formatted; - int capacity = date_string.length() + 1; - - UErrorCode error = U_ZERO_ERROR; - date_string.extract(static_cast<UChar*>(WriteInto(&formatted, capacity)), - capacity, error); - DCHECK(U_SUCCESS(error)); - return formatted; -} - -} // namespace - class TimeRemainingFormat { public: const std::vector<PluralFormat*>& formatter(bool short_version) { @@ -274,7 +253,7 @@ std::wstring TimeFormat::TimeRemainingShort(const TimeDelta& delta) { } // static -std::wstring TimeFormat::FriendlyDay( +std::wstring TimeFormat::RelativeDate( const Time& time, const Time* optional_midnight_today) { Time midnight_today = optional_midnight_today ? *optional_midnight_today : @@ -289,46 +268,3 @@ std::wstring TimeFormat::FriendlyDay( return std::wstring(); } - -std::wstring TimeFormat::TimeOfDay(const Time& time) { - // We can omit the locale parameter because the default should match - // Chrome's application locale. - scoped_ptr<DateFormat> formatter(DateFormat::createTimeInstance( - DateFormat::kShort)); - return FormatTime(formatter.get(), time); -} - -std::wstring TimeFormat::ShortDate(const Time& time) { - scoped_ptr<DateFormat> formatter(DateFormat::createDateInstance( - DateFormat::kMedium)); - return FormatTime(formatter.get(), time); -} - -std::wstring TimeFormat::ShortDateNumeric(const Time& time) { - scoped_ptr<DateFormat> formatter(DateFormat::createDateInstance( - DateFormat::kShort)); - return FormatTime(formatter.get(), time); -} - -std::wstring TimeFormat::FriendlyDateAndTime(const Time& time) { - scoped_ptr<DateFormat> formatter(DateFormat::createDateTimeInstance( - DateFormat::kFull)); - return FormatTime(formatter.get(), time); -} - -std::wstring TimeFormat::FriendlyDate(const Time& time) { - scoped_ptr<DateFormat> formatter(DateFormat::createDateInstance( - DateFormat::kFull)); - return FormatTime(formatter.get(), time); -} - -std::wstring TimeFormat::CookieExpires(const Time& time) { - UErrorCode error = U_ZERO_ERROR; - SimpleDateFormat simple_date_formatter("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'", - Locale::getEnglish(), error); - if (U_FAILURE(error)) - return std::wstring(); - - simple_date_formatter.adoptTimeZone(TimeZone::getGMT()->clone()); - return FormatTime(&simple_date_formatter, time); -} |