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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // down during a single run. | 319 // down during a single run. |
320 const TimeDelta as_time_delta = time_ticks - TimeTicks(); | 320 const TimeDelta as_time_delta = time_ticks - TimeTicks(); |
321 return os << as_time_delta.InMicroseconds() << " bogo-microseconds"; | 321 return os << as_time_delta.InMicroseconds() << " bogo-microseconds"; |
322 } | 322 } |
323 | 323 |
324 std::ostream& operator<<(std::ostream& os, ThreadTicks thread_ticks) { | 324 std::ostream& operator<<(std::ostream& os, ThreadTicks thread_ticks) { |
325 const TimeDelta as_time_delta = thread_ticks - ThreadTicks(); | 325 const TimeDelta as_time_delta = thread_ticks - ThreadTicks(); |
326 return os << as_time_delta.InMicroseconds() << " bogo-thread-microseconds"; | 326 return os << as_time_delta.InMicroseconds() << " bogo-thread-microseconds"; |
327 } | 327 } |
328 | 328 |
329 std::ostream& operator<<(std::ostream& os, TraceTicks trace_ticks) { | |
330 const TimeDelta as_time_delta = trace_ticks - TraceTicks(); | |
331 return os << as_time_delta.InMicroseconds() << " bogo-trace-microseconds"; | |
332 } | |
333 | |
334 // Time::Exploded ------------------------------------------------------------- | 329 // Time::Exploded ------------------------------------------------------------- |
335 | 330 |
336 inline bool is_in_range(int value, int lo, int hi) { | 331 inline bool is_in_range(int value, int lo, int hi) { |
337 return lo <= value && value <= hi; | 332 return lo <= value && value <= hi; |
338 } | 333 } |
339 | 334 |
340 bool Time::Exploded::HasValidValues() const { | 335 bool Time::Exploded::HasValidValues() const { |
341 return is_in_range(month, 1, 12) && | 336 return is_in_range(month, 1, 12) && |
342 is_in_range(day_of_week, 0, 6) && | 337 is_in_range(day_of_week, 0, 6) && |
343 is_in_range(day_of_month, 1, 31) && | 338 is_in_range(day_of_month, 1, 31) && |
344 is_in_range(hour, 0, 23) && | 339 is_in_range(hour, 0, 23) && |
345 is_in_range(minute, 0, 59) && | 340 is_in_range(minute, 0, 59) && |
346 is_in_range(second, 0, 60) && | 341 is_in_range(second, 0, 60) && |
347 is_in_range(millisecond, 0, 999); | 342 is_in_range(millisecond, 0, 999); |
348 } | 343 } |
349 | 344 |
350 } // namespace base | 345 } // namespace base |
OLD | NEW |