| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #if defined(OS_ANDROID) && !defined(__LP64__) | 10 #if defined(OS_ANDROID) && !defined(__LP64__) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // function for TimeTicks::Now() on Mac OS X. | 130 // function for TimeTicks::Now() on Mac OS X. |
| 131 | 131 |
| 132 // Time ----------------------------------------------------------------------- | 132 // Time ----------------------------------------------------------------------- |
| 133 | 133 |
| 134 // Windows uses a Gregorian epoch of 1601. We need to match this internally | 134 // Windows uses a Gregorian epoch of 1601. We need to match this internally |
| 135 // so that our time representations match across all platforms. See bug 14734. | 135 // so that our time representations match across all platforms. See bug 14734. |
| 136 // irb(main):010:0> Time.at(0).getutc() | 136 // irb(main):010:0> Time.at(0).getutc() |
| 137 // => Thu Jan 01 00:00:00 UTC 1970 | 137 // => Thu Jan 01 00:00:00 UTC 1970 |
| 138 // irb(main):011:0> Time.at(-11644473600).getutc() | 138 // irb(main):011:0> Time.at(-11644473600).getutc() |
| 139 // => Mon Jan 01 00:00:00 UTC 1601 | 139 // => Mon Jan 01 00:00:00 UTC 1601 |
| 140 static const int64 kWindowsEpochDeltaSeconds = GG_INT64_C(11644473600); | 140 static const int64 kWindowsEpochDeltaSeconds = INT64_C(11644473600); |
| 141 | 141 |
| 142 // static | 142 // static |
| 143 const int64 Time::kWindowsEpochDeltaMicroseconds = | 143 const int64 Time::kWindowsEpochDeltaMicroseconds = |
| 144 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; | 144 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; |
| 145 | 145 |
| 146 // Some functions in time.cc use time_t directly, so we provide an offset | 146 // Some functions in time.cc use time_t directly, so we provide an offset |
| 147 // to convert from time_t (Unix epoch) and internal (Windows epoch). | 147 // to convert from time_t (Unix epoch) and internal (Windows epoch). |
| 148 // static | 148 // static |
| 149 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; | 149 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; |
| 150 | 150 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; | 386 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; |
| 387 return result; | 387 return result; |
| 388 } | 388 } |
| 389 int64 us = us_ - kTimeTToMicrosecondsOffset; | 389 int64 us = us_ - kTimeTToMicrosecondsOffset; |
| 390 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 390 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 391 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 391 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 392 return result; | 392 return result; |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace base | 395 } // namespace base |
| OLD | NEW |