Index: base/time.cc |
diff --git a/base/time.cc b/base/time.cc |
index 859810e7cfe36b8f894a638803ef2b7a315ae086..bb171c261d9cd12bd574d9807f3e39eb8dfc7756 100644 |
--- a/base/time.cc |
+++ b/base/time.cc |
@@ -3,6 +3,12 @@ |
// found in the LICENSE file. |
#include "base/time.h" |
+ |
+#include <math.h> |
+#if defined(OS_WIN) |
+#include <float.h> |
+#endif |
+ |
#include "base/sys_string_conversions.h" |
#include "base/third_party/nspr/prtime.h" |
@@ -10,6 +16,12 @@ |
namespace base { |
+namespace { |
+#if defined(OS_WIN) |
+inline bool isnan(double num) { return !!_isnan(num); } |
+#endif |
+} |
+ |
// TimeDelta ------------------------------------------------------------------ |
int TimeDelta::InDays() const { |
@@ -66,7 +78,7 @@ time_t Time::ToTimeT() const { |
// static |
Time Time::FromDoubleT(double dt) { |
- if (dt == 0) |
+ if (dt == 0 || isnan(dt)) |
return Time(); // Preserve 0 so we can tell it doesn't exist. |
return Time(static_cast<int64>((dt * |
static_cast<double>(kMicrosecondsPerSecond)) + |