Index: base/time/time_mac.cc |
diff --git a/base/time/time_mac.cc b/base/time/time_mac.cc |
index c75423df9c2229e50fd102efe760191b950a4c71..0ae3a30a3251419baead95006ed1d71843e8750c 100644 |
--- a/base/time/time_mac.cc |
+++ b/base/time/time_mac.cc |
@@ -118,25 +118,6 @@ namespace base { |
// Time ----------------------------------------------------------------------- |
-// Core Foundation uses a double second count since 2001-01-01 00:00:00 UTC. |
-// The UNIX epoch is 1970-01-01 00:00:00 UTC. |
-// Windows uses a Gregorian epoch of 1601. We need to match this internally |
-// so that our time representations match across all platforms. See bug 14734. |
-// irb(main):010:0> Time.at(0).getutc() |
-// => Thu Jan 01 00:00:00 UTC 1970 |
-// irb(main):011:0> Time.at(-11644473600).getutc() |
-// => Mon Jan 01 00:00:00 UTC 1601 |
-static const int64_t kWindowsEpochDeltaSeconds = INT64_C(11644473600); |
- |
-// static |
-const int64_t Time::kWindowsEpochDeltaMicroseconds = |
- kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; |
- |
-// Some functions in time.cc use time_t directly, so we provide an offset |
-// to convert from time_t (Unix epoch) and internal (Windows epoch). |
-// static |
-const int64_t Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; |
- |
// static |
Time Time::Now() { |
return FromCFAbsoluteTime(CFAbsoluteTimeGetCurrent()); |
@@ -152,7 +133,7 @@ Time Time::FromCFAbsoluteTime(CFAbsoluteTime t) { |
return Max(); |
return Time(static_cast<int64_t>((t + kCFAbsoluteTimeIntervalSince1970) * |
kMicrosecondsPerSecond) + |
- kWindowsEpochDeltaMicroseconds); |
+ kTimeTToMicrosecondsOffset); |
} |
CFAbsoluteTime Time::ToCFAbsoluteTime() const { |
@@ -162,8 +143,9 @@ CFAbsoluteTime Time::ToCFAbsoluteTime() const { |
return 0; // Consider 0 as a null Time. |
if (is_max()) |
return std::numeric_limits<CFAbsoluteTime>::infinity(); |
- return (static_cast<CFAbsoluteTime>(us_ - kWindowsEpochDeltaMicroseconds) / |
- kMicrosecondsPerSecond) - kCFAbsoluteTimeIntervalSince1970; |
+ return (static_cast<CFAbsoluteTime>(us_ - kTimeTToMicrosecondsOffset) / |
+ kMicrosecondsPerSecond) - |
+ kCFAbsoluteTimeIntervalSince1970; |
} |
// static |
@@ -194,7 +176,7 @@ bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) { |
// microseconds and then cast to int64. If |
// it cannot be suited to int64, then fail to avoid overflows. |
double microseconds = |
- (seconds * kMicrosecondsPerSecond) + kWindowsEpochDeltaMicroseconds; |
+ (seconds * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset; |
if (microseconds > std::numeric_limits<int64_t>::max() || |
microseconds < std::numeric_limits<int64_t>::min()) { |
*time = Time(0); |
@@ -228,8 +210,8 @@ void Time::Explode(bool is_local, Exploded* exploded) const { |
int64_t microsecond = us_ % kMicrosecondsPerSecond; |
if (microsecond < 0) |
microsecond += kMicrosecondsPerSecond; |
- CFAbsoluteTime seconds = ((us_ - microsecond) / kMicrosecondsPerSecond) - |
- kWindowsEpochDeltaSeconds - |
+ CFAbsoluteTime seconds = ((us_ - microsecond - kTimeTToMicrosecondsOffset) / |
+ kMicrosecondsPerSecond) - |
kCFAbsoluteTimeIntervalSince1970; |
base::ScopedCFTypeRef<CFTimeZoneRef> time_zone( |