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 <math.h> | 7 #include <math.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 return 0; | 131 return 0; |
132 } | 132 } |
133 if (is_max()) { | 133 if (is_max()) { |
134 // Preserve max without offset to prevent overflow. | 134 // Preserve max without offset to prevent overflow. |
135 return std::numeric_limits<double>::max(); | 135 return std::numeric_limits<double>::max(); |
136 } | 136 } |
137 return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) / | 137 return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) / |
138 kMicrosecondsPerMillisecond); | 138 kMicrosecondsPerMillisecond); |
139 } | 139 } |
140 | 140 |
141 int64 Time::ToJavaTime() const { | |
Mark Mentovai
2013/09/20 15:46:25
It looks like, given this and ToJsTime’s equivalen
apiccion
2013/09/20 18:21:48
Thank you!
On 2013/09/20 15:46:25, Mark Mentovai
| |
142 if (is_null()) { | |
143 return 0; | |
Mark Mentovai
2013/09/20 15:46:25
You seem to have copied this from ToJsTime, but yo
apiccion
2013/09/20 18:21:48
Done.
| |
144 } | |
145 if (is_max()) { | |
146 // Preserve max without offset to prevent overflow. | |
147 return std::numeric_limits<long>::max(); | |
Mark Mentovai
2013/09/20 15:46:25
long is the wrong type here.
apiccion
2013/09/20 18:21:48
Done.
| |
148 } | |
149 return ((us_ - kTimeTToMicrosecondsOffset) / | |
150 kMicrosecondsPerMillisecond); | |
151 } | |
152 | |
141 // static | 153 // static |
142 Time Time::UnixEpoch() { | 154 Time Time::UnixEpoch() { |
143 Time time; | 155 Time time; |
144 time.us_ = kTimeTToMicrosecondsOffset; | 156 time.us_ = kTimeTToMicrosecondsOffset; |
145 return time; | 157 return time; |
146 } | 158 } |
147 | 159 |
148 Time Time::LocalMidnight() const { | 160 Time Time::LocalMidnight() const { |
149 Exploded exploded; | 161 Exploded exploded; |
150 LocalExplode(&exploded); | 162 LocalExplode(&exploded); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 return is_in_range(month, 1, 12) && | 198 return is_in_range(month, 1, 12) && |
187 is_in_range(day_of_week, 0, 6) && | 199 is_in_range(day_of_week, 0, 6) && |
188 is_in_range(day_of_month, 1, 31) && | 200 is_in_range(day_of_month, 1, 31) && |
189 is_in_range(hour, 0, 23) && | 201 is_in_range(hour, 0, 23) && |
190 is_in_range(minute, 0, 59) && | 202 is_in_range(minute, 0, 59) && |
191 is_in_range(second, 0, 60) && | 203 is_in_range(second, 0, 60) && |
192 is_in_range(millisecond, 0, 999); | 204 is_in_range(millisecond, 0, 999); |
193 } | 205 } |
194 | 206 |
195 } // namespace base | 207 } // namespace base |
OLD | NEW |