Chromium Code Reviews| 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 <limits> | 7 #include <limits> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 is_local ? PR_FALSE : PR_TRUE, | 182 is_local ? PR_FALSE : PR_TRUE, |
| 183 &result_time); | 183 &result_time); |
| 184 if (PR_SUCCESS != result) | 184 if (PR_SUCCESS != result) |
| 185 return false; | 185 return false; |
| 186 | 186 |
| 187 result_time += kTimeTToMicrosecondsOffset; | 187 result_time += kTimeTToMicrosecondsOffset; |
| 188 *parsed_time = Time(result_time); | 188 *parsed_time = Time(result_time); |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| 191 | 191 |
| 192 // static | |
| 193 TimeTicks TimeTicks::UnixEpoch() { | |
| 194 static const TimeTicks ticks_unix_epoch = | |
|
jar (doing other things)
2013/10/25 01:13:54
My guess is that you want a lazy singleton (probab
| |
| 195 TimeTicks::Now() - (Time::Now() - Time::UnixEpoch()); | |
| 196 return ticks_unix_epoch; | |
| 197 } | |
| 198 | |
| 192 // Time::Exploded ------------------------------------------------------------- | 199 // Time::Exploded ------------------------------------------------------------- |
| 193 | 200 |
| 194 inline bool is_in_range(int value, int lo, int hi) { | 201 inline bool is_in_range(int value, int lo, int hi) { |
| 195 return lo <= value && value <= hi; | 202 return lo <= value && value <= hi; |
| 196 } | 203 } |
| 197 | 204 |
| 198 bool Time::Exploded::HasValidValues() const { | 205 bool Time::Exploded::HasValidValues() const { |
| 199 return is_in_range(month, 1, 12) && | 206 return is_in_range(month, 1, 12) && |
| 200 is_in_range(day_of_week, 0, 6) && | 207 is_in_range(day_of_week, 0, 6) && |
| 201 is_in_range(day_of_month, 1, 31) && | 208 is_in_range(day_of_month, 1, 31) && |
| 202 is_in_range(hour, 0, 23) && | 209 is_in_range(hour, 0, 23) && |
| 203 is_in_range(minute, 0, 59) && | 210 is_in_range(minute, 0, 59) && |
| 204 is_in_range(second, 0, 60) && | 211 is_in_range(second, 0, 60) && |
| 205 is_in_range(millisecond, 0, 999); | 212 is_in_range(millisecond, 0, 999); |
| 206 } | 213 } |
| 207 | 214 |
| 208 } // namespace base | 215 } // namespace base |
| OLD | NEW |