OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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.h" | 5 #include "base/time.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "base/third_party/nspr/prtime.h" | 8 #include "base/third_party/nspr/prtime.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 PRTime result_time = 0; | 98 PRTime result_time = 0; |
99 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, | 99 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, |
100 &result_time); | 100 &result_time); |
101 if (PR_SUCCESS != result) | 101 if (PR_SUCCESS != result) |
102 return false; | 102 return false; |
103 result_time += kTimeTToMicrosecondsOffset; | 103 result_time += kTimeTToMicrosecondsOffset; |
104 *parsed_time = Time(result_time); | 104 *parsed_time = Time(result_time); |
105 return true; | 105 return true; |
106 } | 106 } |
107 | 107 |
| 108 // Time::Exploded ------------------------------------------------------------- |
| 109 |
| 110 inline bool is_in_range(int value, int lo, int hi) { |
| 111 return lo <= value && value <= hi; |
| 112 } |
| 113 |
| 114 bool Time::Exploded::HasValidValues() const { |
| 115 return is_in_range(month, 1, 12) && |
| 116 is_in_range(day_of_week, 0, 6) && |
| 117 is_in_range(day_of_month, 1, 31) && |
| 118 is_in_range(hour, 0, 23) && |
| 119 is_in_range(minute, 0, 59) && |
| 120 is_in_range(second, 0, 60) && |
| 121 is_in_range(millisecond, 0, 999); |
| 122 } |
| 123 |
108 } // namespace base | 124 } // namespace base |
OLD | NEW |