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

Unified Diff: base/time_win.cc

Issue 10916089: Fixing Time::Max()'s behavior with Time::ToTimeT() and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scary casting. Created 8 years, 3 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
« base/time_unittest.cc ('K') | « base/time_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time_win.cc
diff --git a/base/time_win.cc b/base/time_win.cc
index 191b7a779881026f54573e4a00c8658ade9ccc12..b59dab2811f1519da9ffec7bf75252d1e853c403 100644
--- a/base/time_win.cc
+++ b/base/time_win.cc
@@ -141,10 +141,18 @@ Time Time::NowFromSystemTime() {
// static
Time Time::FromFileTime(FILETIME ft) {
+ if (bit_cast<int64, FILETIME>(ft) == 0)
+ return Time();
+ if (bit_cast<int64, FILETIME>(ft) == std::numeric_limits<int64>::max())
+ return Max();
return Time(FileTimeToMicroseconds(ft));
}
FILETIME Time::ToFileTime() const {
+ if (is_null())
+ return bit_cast<FILETIME, int64>(0);
+ if (is_max())
+ return bit_cast<FILETIME, int64>(std::numeric_limits<int64>::max());
FILETIME utc_ft;
MicrosecondsToFileTime(us_, &utc_ft);
return utc_ft;
« base/time_unittest.cc ('K') | « base/time_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698