Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3146)

Unified Diff: base/time.cc

Issue 10447110: WebKit will start using NaN to indicate null/invalid time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) +
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698