summaryrefslogtreecommitdiffstats
path: root/base/time.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-06 05:04:22 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-06 05:04:22 +0000
commit527c7f372a3362b009831407126e34647dbe30bd (patch)
tree86ae9b79d4f377e31690588d9ee8fb7d3d3872b1 /base/time.cc
parent1d46f5d4cfee5ea6d82305eed25aa94a8a6738a5 (diff)
downloadchromium_src-527c7f372a3362b009831407126e34647dbe30bd.zip
chromium_src-527c7f372a3362b009831407126e34647dbe30bd.tar.gz
chromium_src-527c7f372a3362b009831407126e34647dbe30bd.tar.bz2
WebKit will start using NaN for null/invalid modificationTime
Per discussion on webkit bugzilla WebKit will start using NaN for null/invalidmodificationTime (instead of 0.0, our conventional null time value) https://bugs.webkit.org/show_bug.cgi?id=87709#c10 https://bugs.webkit.org/show_bug.cgi?id=87826 BUG=none TEST=existing tests should pass Review URL: https://chromiumcodereview.appspot.com/10447110 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time.cc')
-rw-r--r--base/time.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/base/time.cc b/base/time.cc
index 859810e..39a8b56 100644
--- a/base/time.cc
+++ b/base/time.cc
@@ -1,8 +1,14 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// 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)) +