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 <CoreFoundation/CFDate.h> | 7 #include <CoreFoundation/CFDate.h> |
8 #include <CoreFoundation/CFTimeZone.h> | 8 #include <CoreFoundation/CFTimeZone.h> |
9 #include <mach/mach_time.h> | 9 #include <mach/mach_time.h> |
10 #include <sys/sysctl.h> | 10 #include <sys/sysctl.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 // Core Foundation uses a double second count since 2001-01-01 00:00:00 UTC. | 79 // Core Foundation uses a double second count since 2001-01-01 00:00:00 UTC. |
80 // The UNIX epoch is 1970-01-01 00:00:00 UTC. | 80 // The UNIX epoch is 1970-01-01 00:00:00 UTC. |
81 // Windows uses a Gregorian epoch of 1601. We need to match this internally | 81 // Windows uses a Gregorian epoch of 1601. We need to match this internally |
82 // so that our time representations match across all platforms. See bug 14734. | 82 // so that our time representations match across all platforms. See bug 14734. |
83 // irb(main):010:0> Time.at(0).getutc() | 83 // irb(main):010:0> Time.at(0).getutc() |
84 // => Thu Jan 01 00:00:00 UTC 1970 | 84 // => Thu Jan 01 00:00:00 UTC 1970 |
85 // irb(main):011:0> Time.at(-11644473600).getutc() | 85 // irb(main):011:0> Time.at(-11644473600).getutc() |
86 // => Mon Jan 01 00:00:00 UTC 1601 | 86 // => Mon Jan 01 00:00:00 UTC 1601 |
87 static const int64 kWindowsEpochDeltaSeconds = GG_INT64_C(11644473600); | 87 static const int64 kWindowsEpochDeltaSeconds = GG_INT64_C(11644473600); |
88 static const int64 kWindowsEpochDeltaMilliseconds = | |
89 kWindowsEpochDeltaSeconds * Time::kMillisecondsPerSecond; | |
90 | 88 |
91 // static | 89 // static |
92 const int64 Time::kWindowsEpochDeltaMicroseconds = | 90 const int64 Time::kWindowsEpochDeltaMicroseconds = |
93 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; | 91 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; |
94 | 92 |
95 // Some functions in time.cc use time_t directly, so we provide an offset | 93 // Some functions in time.cc use time_t directly, so we provide an offset |
96 // to convert from time_t (Unix epoch) and internal (Windows epoch). | 94 // to convert from time_t (Unix epoch) and internal (Windows epoch). |
97 // static | 95 // static |
98 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; | 96 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; |
99 | 97 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 NOTREACHED(); | 194 NOTREACHED(); |
197 return TimeTicks(); | 195 return TimeTicks(); |
198 } | 196 } |
199 | 197 |
200 // static | 198 // static |
201 TimeTicks TimeTicks::NowFromSystemTraceTime() { | 199 TimeTicks TimeTicks::NowFromSystemTraceTime() { |
202 return HighResNow(); | 200 return HighResNow(); |
203 } | 201 } |
204 | 202 |
205 } // namespace base | 203 } // namespace base |
OLD | NEW |