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> |
11 #include <sstream> | 11 #include <sstream> |
12 | 12 |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/third_party/nspr/prtime.h" | 17 #include "base/third_party/nspr/prtime.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 // TimeDelta ------------------------------------------------------------------ | 22 // TimeDelta ------------------------------------------------------------------ |
23 | 23 |
| 24 // static |
| 25 TimeDelta TimeDelta::Max() { |
| 26 return TimeDelta(std::numeric_limits<int64_t>::max()); |
| 27 } |
| 28 |
24 int TimeDelta::InDays() const { | 29 int TimeDelta::InDays() const { |
25 if (is_max()) { | 30 if (is_max()) { |
26 // Preserve max to prevent overflow. | 31 // Preserve max to prevent overflow. |
27 return std::numeric_limits<int>::max(); | 32 return std::numeric_limits<int>::max(); |
28 } | 33 } |
29 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); | 34 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); |
30 } | 35 } |
31 | 36 |
32 int TimeDelta::InHours() const { | 37 int TimeDelta::InHours() const { |
33 if (is_max()) { | 38 if (is_max()) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 return is_in_range(month, 1, 12) && | 342 return is_in_range(month, 1, 12) && |
338 is_in_range(day_of_week, 0, 6) && | 343 is_in_range(day_of_week, 0, 6) && |
339 is_in_range(day_of_month, 1, 31) && | 344 is_in_range(day_of_month, 1, 31) && |
340 is_in_range(hour, 0, 23) && | 345 is_in_range(hour, 0, 23) && |
341 is_in_range(minute, 0, 59) && | 346 is_in_range(minute, 0, 59) && |
342 is_in_range(second, 0, 60) && | 347 is_in_range(second, 0, 60) && |
343 is_in_range(millisecond, 0, 999); | 348 is_in_range(millisecond, 0, 999); |
344 } | 349 } |
345 | 350 |
346 } // namespace base | 351 } // namespace base |
OLD | NEW |