diff options
author | mkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-08 17:50:07 +0000 |
---|---|---|
committer | mkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-08 17:50:07 +0000 |
commit | a9e5f04481565af0a3c8dbe770b14899f24b68f7 (patch) | |
tree | 4565198c5cdff1435acd19f5efc903eb306ee061 /base/time_win.cc | |
parent | 4a6d53c71fb914da3dd9e15cdc72b385b91701ec (diff) | |
download | chromium_src-a9e5f04481565af0a3c8dbe770b14899f24b68f7.zip chromium_src-a9e5f04481565af0a3c8dbe770b14899f24b68f7.tar.gz chromium_src-a9e5f04481565af0a3c8dbe770b14899f24b68f7.tar.bz2 |
Fixing Time::Max()'s behavior with Time::ToTimeT() and friends.
It looks like the math that's done to convert epoch times between platforms is
giving incorrect results when confronted with a "max" time. This CL adjusts the
various conversion methods to persist maxness in the same way they currently
persist zeroness.
BUG=146328
Review URL: https://chromiumcodereview.appspot.com/10916089
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time_win.cc')
-rw-r--r-- | base/time_win.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/base/time_win.cc b/base/time_win.cc index 191b7a7..6d8e432 100644 --- a/base/time_win.cc +++ b/base/time_win.cc @@ -141,10 +141,23 @@ Time Time::NowFromSystemTime() { // static Time Time::FromFileTime(FILETIME ft) { + if (bit_cast<int64, FILETIME>(ft) == 0) + return Time(); + if (ft.dwHighDateTime == std::numeric_limits<DWORD>::max() && + ft.dwLowDateTime == std::numeric_limits<DWORD>::max()) + return Max(); return Time(FileTimeToMicroseconds(ft)); } FILETIME Time::ToFileTime() const { + if (is_null()) + return bit_cast<FILETIME, int64>(0); + if (is_max()) { + FILETIME result; + result.dwHighDateTime = std::numeric_limits<DWORD>::max(); + result.dwLowDateTime = std::numeric_limits<DWORD>::max(); + return result; + } FILETIME utc_ft; MicrosecondsToFileTime(us_, &utc_ft); return utc_ft; |