| Index: base/time.cc
|
| diff --git a/base/time.cc b/base/time.cc
|
| index 7055311e80e7d53df843b61dd63a67b816a74faa..89293d1b77d9c7d9c2c49298c3a18a8c14106d1c 100644
|
| --- a/base/time.cc
|
| +++ b/base/time.cc
|
| @@ -74,12 +74,16 @@ Time Time::Max() {
|
| Time Time::FromTimeT(time_t tt) {
|
| if (tt == 0)
|
| return Time(); // Preserve 0 so we can tell it doesn't exist.
|
| + if (tt == std::numeric_limits<time_t>::max())
|
| + return Max(); // Max is max.
|
| return Time((tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset);
|
| }
|
|
|
| time_t Time::ToTimeT() const {
|
| if (us_ == 0)
|
| return 0; // Preserve 0 so we can tell it doesn't exist.
|
| + if (is_max())
|
| + return std::numeric_limits<time_t>::max();
|
| return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond;
|
| }
|
|
|
| @@ -87,6 +91,8 @@ time_t Time::ToTimeT() const {
|
| Time Time::FromDoubleT(double dt) {
|
| if (dt == 0 || isnan(dt))
|
| return Time(); // Preserve 0 so we can tell it doesn't exist.
|
| + if (dt == std::numeric_limits<double>::max())
|
| + return Max(); // Max is max.
|
| return Time(static_cast<int64>((dt *
|
| static_cast<double>(kMicrosecondsPerSecond)) +
|
| kTimeTToMicrosecondsOffset));
|
| @@ -95,6 +101,8 @@ Time Time::FromDoubleT(double dt) {
|
| double Time::ToDoubleT() const {
|
| if (us_ == 0)
|
| return 0; // Preserve 0 so we can tell it doesn't exist.
|
| + if (is_max())
|
| + return std::numeric_limits<double>::max(); // Max is max.
|
| return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) /
|
| static_cast<double>(kMicrosecondsPerSecond));
|
| }
|
| @@ -103,15 +111,17 @@ double Time::ToDoubleT() const {
|
| Time Time::FromJsTime(double ms_since_epoch) {
|
| // The epoch is a valid time, so this constructor doesn't interpret
|
| // 0 as the null time.
|
| + if (ms_since_epoch == std::numeric_limits<double>::max())
|
| + return Max(); // Max is max.
|
| return Time(static_cast<int64>(ms_since_epoch * kMicrosecondsPerMillisecond) +
|
| kTimeTToMicrosecondsOffset);
|
| }
|
|
|
| double Time::ToJsTime() const {
|
| - if (us_ == 0) {
|
| - // Preserve 0 so the invalid result doesn't depend on the platform.
|
| - return 0;
|
| - }
|
| + if (us_ == 0)
|
| + return 0; // Preserve 0 so the invalid result doesn't depend on a platform.
|
| + if (is_max())
|
| + return std::numeric_limits<double>::max();
|
| return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) /
|
| kMicrosecondsPerMillisecond);
|
| }
|
|
|