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 | |
29 int TimeDelta::InDays() const { | 24 int TimeDelta::InDays() const { |
30 if (is_max()) { | 25 if (is_max()) { |
31 // Preserve max to prevent overflow. | 26 // Preserve max to prevent overflow. |
32 return std::numeric_limits<int>::max(); | 27 return std::numeric_limits<int>::max(); |
33 } | 28 } |
34 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); | 29 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); |
35 } | 30 } |
36 | 31 |
37 int TimeDelta::InHours() const { | 32 int TimeDelta::InHours() const { |
38 if (is_max()) { | 33 if (is_max()) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return is_in_range(month, 1, 12) && | 337 return is_in_range(month, 1, 12) && |
343 is_in_range(day_of_week, 0, 6) && | 338 is_in_range(day_of_week, 0, 6) && |
344 is_in_range(day_of_month, 1, 31) && | 339 is_in_range(day_of_month, 1, 31) && |
345 is_in_range(hour, 0, 23) && | 340 is_in_range(hour, 0, 23) && |
346 is_in_range(minute, 0, 59) && | 341 is_in_range(minute, 0, 59) && |
347 is_in_range(second, 0, 60) && | 342 is_in_range(second, 0, 60) && |
348 is_in_range(millisecond, 0, 999); | 343 is_in_range(millisecond, 0, 999); |
349 } | 344 } |
350 | 345 |
351 } // namespace base | 346 } // namespace base |
OLD | NEW |