Make int64 -> Time conversion explicit.
Landing Patch for Jacob Mandelson, original review: http://codereview.chromium.org/200093
BUG=none
TEST=base_unittests & app_unittests
Review URL: http://codereview.chromium.org/205003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26134 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: b842d4c63ecce6aacb5aa1e184582ee1c5ce4a9e
diff --git a/base/time.cc b/base/time.cc
index 992e256..afe8c8f 100644
--- a/base/time.cc
+++ b/base/time.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -51,7 +51,7 @@
Time Time::FromTimeT(time_t tt) {
if (tt == 0)
return Time(); // Preserve 0 so we can tell it doesn't exist.
- return (tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset;
+ return Time((tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset);
}
time_t Time::ToTimeT() const {
@@ -62,8 +62,9 @@
// static
Time Time::FromDoubleT(double dt) {
- return (dt * static_cast<double>(kMicrosecondsPerSecond)) +
- kTimeTToMicrosecondsOffset;
+ return Time(static_cast<int64>((dt *
+ static_cast<double>(kMicrosecondsPerSecond)) +
+ kTimeTToMicrosecondsOffset));
}
double Time::ToDoubleT() const {
diff --git a/base/time.h b/base/time.h
index a57c04f..6a181af 100644
--- a/base/time.h
+++ b/base/time.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -313,10 +313,10 @@
// Return a new time modified by some delta.
Time operator+(TimeDelta delta) const {
- return us_ + delta.delta_;
+ return Time(us_ + delta.delta_);
}
Time operator-(TimeDelta delta) const {
- return us_ - delta.delta_;
+ return Time(us_ - delta.delta_);
}
// Comparison operators
@@ -350,7 +350,7 @@
// |is_local = true| or UTC |is_local = false|.
static Time FromExploded(bool is_local, const Exploded& exploded);
- Time(int64 us) : us_(us) {
+ explicit Time(int64 us) : us_(us) {
}
// The representation of Jan 1, 1970 UTC in microseconds since the