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

Side by Side Diff: content/renderer/date_time_formatter.cc

Issue 17574002: When using the week-of-year syntax, don't construct an intermediate time value when formatting; use… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-enable test Created 7 years, 6 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 | « no previous file | content/renderer/date_time_formatter_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/renderer/date_time_formatter.h" 5 #include "content/renderer/date_time_formatter.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "third_party/WebKit/public/platform/WebCString.h" 9 #include "third_party/WebKit/public/platform/WebCString.h"
10 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" 10 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 calendar.set(UCAL_YEAR_WOY, week_year_); 123 calendar.set(UCAL_YEAR_WOY, week_year_);
124 calendar.set(UCAL_WEEK_OF_YEAR, week_); 124 calendar.set(UCAL_WEEK_OF_YEAR, week_);
125 } else { 125 } else {
126 calendar.set(UCAL_YEAR, year_); 126 calendar.set(UCAL_YEAR, year_);
127 calendar.set(UCAL_MONTH, month_); 127 calendar.set(UCAL_MONTH, month_);
128 calendar.set(UCAL_DATE, day_); 128 calendar.set(UCAL_DATE, day_);
129 calendar.set(UCAL_HOUR_OF_DAY, hour_); 129 calendar.set(UCAL_HOUR_OF_DAY, hour_);
130 calendar.set(UCAL_MINUTE, minute_); 130 calendar.set(UCAL_MINUTE, minute_);
131 calendar.set(UCAL_SECOND, second_); 131 calendar.set(UCAL_SECOND, second_);
132 } 132 }
133 UDate time = calendar.getTime(success);
134 icu::SimpleDateFormat formatter(*pattern_, success); 133 icu::SimpleDateFormat formatter(*pattern_, success);
135 icu::UnicodeString formatted_time; 134 icu::UnicodeString formatted_time;
136 formatter.format(time, formatted_time, success); 135 formatter.format(calendar, formatted_time, NULL, success);
137 UTF16ToUTF8(formatted_time.getBuffer(), 136 UTF16ToUTF8(formatted_time.getBuffer(),
138 static_cast<size_t>(formatted_time.length()), 137 static_cast<size_t>(formatted_time.length()),
139 &result); 138 &result);
140 if (success <= U_ZERO_ERROR) 139 if (success <= U_ZERO_ERROR)
141 return result; 140 return result;
142 } 141 }
143 LOG(WARNING) << "Calendar not created: error " << success; 142 LOG(WARNING) << "Calendar not created: error " << success;
144 return std::string(); 143 return std::string();
145 } 144 }
146 145
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 month_ = 0; 218 month_ = 0;
220 day_ = 0; 219 day_ = 0;
221 hour_ = 0; 220 hour_ = 0;
222 minute_ = 0; 221 minute_ = 0;
223 second_ = 0; 222 second_ = 0;
224 week_year_ = 0; 223 week_year_ = 0;
225 week_ = 0; 224 week_ = 0;
226 } 225 }
227 226
228 } // namespace content 227 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/date_time_formatter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698