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

Side by Side Diff: base/i18n/time_formatting.cc

Issue 678001: base: string_util.h -> utf_string_conversions.h fix. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/i18n/file_util_icu.cc ('k') | base/json/string_escape_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/i18n/time_formatting.h" 5 #include "base/i18n/time_formatting.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "unicode/datefmt.h" 11 #include "unicode/datefmt.h"
12 12
13 using base::Time; 13 using base::Time;
14 14
15 namespace { 15 namespace {
16 16
17 std::wstring TimeFormat(const icu::DateFormat* formatter, 17 std::wstring TimeFormat(const icu::DateFormat* formatter,
18 const Time& time) { 18 const Time& time) {
19 DCHECK(formatter); 19 DCHECK(formatter);
20 icu::UnicodeString date_string; 20 icu::UnicodeString date_string;
21 21
22 formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string); 22 formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string);
23 std::wstring output; 23 std::wstring output;
24 bool success = UTF16ToWide(date_string.getBuffer(), date_string.length(), 24 bool success = UTF16ToWide(date_string.getBuffer(), date_string.length(),
25 &output); 25 &output);
26 DCHECK(success); 26 DCHECK(success);
27 return output; 27 return output;
28 } 28 }
29 29
30 } 30 } // namespace
31 31
32 namespace base { 32 namespace base {
33 33
34 std::wstring TimeFormatTimeOfDay(const Time& time) { 34 std::wstring TimeFormatTimeOfDay(const Time& time) {
35 // We can omit the locale parameter because the default should match 35 // We can omit the locale parameter because the default should match
36 // Chrome's application locale. 36 // Chrome's application locale.
37 scoped_ptr<icu::DateFormat> formatter( 37 scoped_ptr<icu::DateFormat> formatter(
38 icu::DateFormat::createTimeInstance(icu::DateFormat::kShort)); 38 icu::DateFormat::createTimeInstance(icu::DateFormat::kShort));
39 return TimeFormat(formatter.get(), time); 39 return TimeFormat(formatter.get(), time);
40 } 40 }
(...skipping 22 matching lines...) Expand all
63 return TimeFormat(formatter.get(), time); 63 return TimeFormat(formatter.get(), time);
64 } 64 }
65 65
66 std::wstring TimeFormatFriendlyDate(const Time& time) { 66 std::wstring TimeFormatFriendlyDate(const Time& time) {
67 scoped_ptr<icu::DateFormat> formatter(icu::DateFormat::createDateInstance( 67 scoped_ptr<icu::DateFormat> formatter(icu::DateFormat::createDateInstance(
68 icu::DateFormat::kFull)); 68 icu::DateFormat::kFull));
69 return TimeFormat(formatter.get(), time); 69 return TimeFormat(formatter.get(), time);
70 } 70 }
71 71
72 } // namespace base 72 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/file_util_icu.cc ('k') | base/json/string_escape_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698