diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-09 17:17:55 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-09 17:17:55 +0000 |
commit | c925ad166b4825c6412a318092a664da58b5f365 (patch) | |
tree | ea292d1cdcb394ef50c93f57b20cf7f35a1ffac0 /base/time.cc | |
parent | feed0677b1f7f719498d3b08f0dab523a4c095e7 (diff) | |
download | chromium_src-c925ad166b4825c6412a318092a664da58b5f365.zip chromium_src-c925ad166b4825c6412a318092a664da58b5f365.tar.gz chromium_src-c925ad166b4825c6412a318092a664da58b5f365.tar.bz2 |
Fix Time::FromDoubleT so that it will return null time when 0 is passed.
This is the rework of this issue before previous submit is reverted. We need to
fix the usage of Time::FromDoubleT(0) in extension history API.
BUG=none
TEST=non
Review URL: http://codereview.chromium.org/3295001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time.cc')
-rw-r--r-- | base/time.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/base/time.cc b/base/time.cc index 383f939..766f599 100644 --- a/base/time.cc +++ b/base/time.cc @@ -66,6 +66,8 @@ time_t Time::ToTimeT() const { // static Time Time::FromDoubleT(double dt) { + if (dt == 0) + return Time(); // Preserve 0 so we can tell it doesn't exist. return Time(static_cast<int64>((dt * static_cast<double>(kMicrosecondsPerSecond)) + kTimeTToMicrosecondsOffset)); @@ -78,6 +80,13 @@ double Time::ToDoubleT() const { static_cast<double>(kMicrosecondsPerSecond)); } +// static +Time Time::UnixEpoch() { + Time time; + time.us_ = kTimeTToMicrosecondsOffset; + return time; +} + Time Time::LocalMidnight() const { Exploded exploded; LocalExplode(&exploded); |