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> |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return rv.ValueOrDie(); | 119 return rv.ValueOrDie(); |
120 // Negative RHS overflows. Positive RHS underflows. | 120 // Negative RHS overflows. Positive RHS underflows. |
121 if (value < 0) | 121 if (value < 0) |
122 return std::numeric_limits<int64_t>::max(); | 122 return std::numeric_limits<int64_t>::max(); |
123 return -std::numeric_limits<int64_t>::max(); | 123 return -std::numeric_limits<int64_t>::max(); |
124 } | 124 } |
125 | 125 |
126 } // namespace time_internal | 126 } // namespace time_internal |
127 | 127 |
128 std::ostream& operator<<(std::ostream& os, TimeDelta time_delta) { | 128 std::ostream& operator<<(std::ostream& os, TimeDelta time_delta) { |
129 return os << time_delta.InSecondsF() << "s"; | 129 return os << time_delta.InSecondsF() << " s"; |
130 } | 130 } |
131 | 131 |
132 // Time ----------------------------------------------------------------------- | 132 // Time ----------------------------------------------------------------------- |
133 | 133 |
134 // static | 134 // static |
135 Time Time::FromTimeT(time_t tt) { | 135 Time Time::FromTimeT(time_t tt) { |
136 if (tt == 0) | 136 if (tt == 0) |
137 return Time(); // Preserve 0 so we can tell it doesn't exist. | 137 return Time(); // Preserve 0 so we can tell it doesn't exist. |
138 if (tt == std::numeric_limits<time_t>::max()) | 138 if (tt == std::numeric_limits<time_t>::max()) |
139 return Max(); | 139 return Max(); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 return is_in_range(month, 1, 12) && | 337 return is_in_range(month, 1, 12) && |
338 is_in_range(day_of_week, 0, 6) && | 338 is_in_range(day_of_week, 0, 6) && |
339 is_in_range(day_of_month, 1, 31) && | 339 is_in_range(day_of_month, 1, 31) && |
340 is_in_range(hour, 0, 23) && | 340 is_in_range(hour, 0, 23) && |
341 is_in_range(minute, 0, 59) && | 341 is_in_range(minute, 0, 59) && |
342 is_in_range(second, 0, 60) && | 342 is_in_range(second, 0, 60) && |
343 is_in_range(millisecond, 0, 999); | 343 is_in_range(millisecond, 0, 999); |
344 } | 344 } |
345 | 345 |
346 } // namespace base | 346 } // namespace base |
OLD | NEW |