OLD | NEW |
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 Loading... |
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 |
266 std::ostream& operator<<(std::ostream& os, Time time) { | 274 std::ostream& operator<<(std::ostream& os, Time time) { |
267 Time::Exploded exploded; | 275 Time::Exploded exploded; |
268 time.UTCExplode(&exploded); | 276 time.UTCExplode(&exploded); |
269 // Use StringPrintf because iostreams formatting is painful. | 277 // Use StringPrintf because iostreams formatting is painful. |
270 return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", | 278 return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", |
271 exploded.year, | 279 exploded.year, |
272 exploded.month, | 280 exploded.month, |
273 exploded.day_of_month, | 281 exploded.day_of_month, |
274 exploded.hour, | 282 exploded.hour, |
275 exploded.minute, | 283 exploded.minute, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 return is_in_range(month, 1, 12) && | 346 return is_in_range(month, 1, 12) && |
339 is_in_range(day_of_week, 0, 6) && | 347 is_in_range(day_of_week, 0, 6) && |
340 is_in_range(day_of_month, 1, 31) && | 348 is_in_range(day_of_month, 1, 31) && |
341 is_in_range(hour, 0, 23) && | 349 is_in_range(hour, 0, 23) && |
342 is_in_range(minute, 0, 59) && | 350 is_in_range(minute, 0, 59) && |
343 is_in_range(second, 0, 60) && | 351 is_in_range(second, 0, 60) && |
344 is_in_range(millisecond, 0, 999); | 352 is_in_range(millisecond, 0, 999); |
345 } | 353 } |
346 | 354 |
347 } // namespace base | 355 } // namespace base |
OLD | NEW |