diff options
author | dbeam <dbeam@chromium.org> | 2015-08-19 12:38:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-19 19:39:06 +0000 |
commit | 9c33158ca8cae4ad4e62e09d77ea2990a9945c0c (patch) | |
tree | 257ac0637a7cb417c39ccc8c52bf3e7872457283 | |
parent | cbeb524863c8b41435b14a64a78e0697021b8a25 (diff) | |
download | chromium_src-9c33158ca8cae4ad4e62e09d77ea2990a9945c0c.zip chromium_src-9c33158ca8cae4ad4e62e09d77ea2990a9945c0c.tar.gz chromium_src-9c33158ca8cae4ad4e62e09d77ea2990a9945c0c.tar.bz2 |
MD Downloads: show long month (i.e. August instead of Aug)
R=thestig@chromium.org
BUG=520722
Review URL: https://codereview.chromium.org/1301833004
Cr-Commit-Position: refs/heads/master@{#344305}
-rw-r--r-- | chrome/browser/ui/webui/downloads_dom_handler.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc index 5858b57..83d5cfd 100644 --- a/chrome/browser/ui/webui/downloads_dom_handler.cc +++ b/chrome/browser/ui/webui/downloads_dom_handler.cc @@ -50,6 +50,7 @@ #include "content/public/browser/web_ui.h" #include "extensions/browser/extension_system.h" #include "net/base/filename_util.h" +#include "third_party/icu/source/i18n/unicode/datefmt.h" #include "ui/base/l10n/time_format.h" #include "ui/gfx/image/image.h" @@ -111,6 +112,16 @@ const char* GetDangerTypeString(content::DownloadDangerType danger_type) { } } +// TODO(dbeam): if useful elsewhere, move to base/i18n/time_formatting.h? +base::string16 TimeFormatLongDate(const base::Time& time) { + scoped_ptr<icu::DateFormat> formatter( + icu::DateFormat::createDateInstance(icu::DateFormat::kLong)); + icu::UnicodeString date_string; + formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string); + return base::string16(date_string.getBuffer(), + static_cast<size_t>(date_string.length())); +} + // Returns a JSON dictionary containing some of the attributes of |download|. // The JSON dictionary will also have a field "id" set to |id|, and a field // "otr" set to |incognito|. @@ -133,8 +144,12 @@ base::DictionaryValue* CreateDownloadItemValue( file_value->SetString( "since_string", ui::TimeFormat::RelativeDate( download_item->GetStartTime(), NULL)); - file_value->SetString( - "date_string", base::TimeFormatShortDate(download_item->GetStartTime())); + + base::Time start_time = download_item->GetStartTime(); + base::string16 date_string = switches::MdDownloadsEnabled() ? + TimeFormatLongDate(start_time) : base::TimeFormatShortDate(start_time); + file_value->SetString("date_string", date_string); + file_value->SetString("id", base::Uint64ToString(download_item->GetId())); base::FilePath download_path(download_item->GetTargetFilePath()); |