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

Side by Side Diff: base/time/time.cc

Issue 2022913002: Revert of Add: check exploded time is properly converted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « base/time/time.h ('k') | base/time/time_mac.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/time/time.h" 5 #include "base/time/time.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <ios> 8 #include <ios>
9 #include <limits> 9 #include <limits>
10 #include <ostream> 10 #include <ostream>
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 is_local ? PR_FALSE : PR_TRUE, 256 is_local ? PR_FALSE : PR_TRUE,
257 &result_time); 257 &result_time);
258 if (PR_SUCCESS != result) 258 if (PR_SUCCESS != result)
259 return false; 259 return false;
260 260
261 result_time += kTimeTToMicrosecondsOffset; 261 result_time += kTimeTToMicrosecondsOffset;
262 *parsed_time = Time(result_time); 262 *parsed_time = Time(result_time);
263 return true; 263 return true;
264 } 264 }
265 265
266 // static
267 bool Time::ExplodedMostlyEquals(const Exploded& lhs, const Exploded& rhs) {
268 return lhs.year == rhs.year && lhs.month == rhs.month &&
269 lhs.day_of_month == rhs.day_of_month && lhs.hour == rhs.hour &&
270 lhs.minute == rhs.minute && lhs.second == rhs.second &&
271 lhs.millisecond == rhs.millisecond;
272 }
273
274 std::ostream& operator<<(std::ostream& os, Time time) { 266 std::ostream& operator<<(std::ostream& os, Time time) {
275 Time::Exploded exploded; 267 Time::Exploded exploded;
276 time.UTCExplode(&exploded); 268 time.UTCExplode(&exploded);
277 // Use StringPrintf because iostreams formatting is painful. 269 // Use StringPrintf because iostreams formatting is painful.
278 return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", 270 return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC",
279 exploded.year, 271 exploded.year,
280 exploded.month, 272 exploded.month,
281 exploded.day_of_month, 273 exploded.day_of_month,
282 exploded.hour, 274 exploded.hour,
283 exploded.minute, 275 exploded.minute,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return is_in_range(month, 1, 12) && 338 return is_in_range(month, 1, 12) &&
347 is_in_range(day_of_week, 0, 6) && 339 is_in_range(day_of_week, 0, 6) &&
348 is_in_range(day_of_month, 1, 31) && 340 is_in_range(day_of_month, 1, 31) &&
349 is_in_range(hour, 0, 23) && 341 is_in_range(hour, 0, 23) &&
350 is_in_range(minute, 0, 59) && 342 is_in_range(minute, 0, 59) &&
351 is_in_range(second, 0, 60) && 343 is_in_range(second, 0, 60) &&
352 is_in_range(millisecond, 0, 999); 344 is_in_range(millisecond, 0, 999);
353 } 345 }
354 346
355 } // namespace base 347 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time.h ('k') | base/time/time_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698