Chromium Code Reviews| Index: base/time/time.cc |
| diff --git a/base/time/time.cc b/base/time/time.cc |
| index 8cbb382bb9616dfc6ed2e7f0742630845745aa62..10ffcc606651b9a2e7ab147620d30cdb9351a443 100644 |
| --- a/base/time/time.cc |
| +++ b/base/time/time.cc |
| @@ -144,7 +144,7 @@ Time Time::FromTimeT(time_t tt) { |
| return Time(); // Preserve 0 so we can tell it doesn't exist. |
| if (tt == std::numeric_limits<time_t>::max()) |
| return Max(); |
| - return Time((tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset); |
| + return Time(kTimeTToMicrosecondsOffset) + TimeDelta::FromSeconds(tt); |
|
Nico
2015/07/17 17:00:23
I like the changes in this file :-)
|
| } |
| time_t Time::ToTimeT() const { |
| @@ -166,11 +166,7 @@ time_t Time::ToTimeT() const { |
| Time Time::FromDoubleT(double dt) { |
| if (dt == 0 || std::isnan(dt)) |
| return Time(); // Preserve 0 so we can tell it doesn't exist. |
| - if (dt == std::numeric_limits<double>::infinity()) |
| - return Max(); |
| - return Time(static_cast<int64>((dt * |
| - static_cast<double>(kMicrosecondsPerSecond)) + |
| - kTimeTToMicrosecondsOffset)); |
| + return Time(kTimeTToMicrosecondsOffset) + TimeDelta::FromSecondsD(dt); |
| } |
| double Time::ToDoubleT() const { |
| @@ -197,10 +193,8 @@ Time Time::FromTimeSpec(const timespec& ts) { |
| 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>::infinity()) |
| - return Max(); |
| - return Time(static_cast<int64>(ms_since_epoch * kMicrosecondsPerMillisecond) + |
| - kTimeTToMicrosecondsOffset); |
| + return Time(kTimeTToMicrosecondsOffset) + |
| + TimeDelta::FromMillisecondsD(ms_since_epoch); |
| } |
| double Time::ToJsTime() const { |