OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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.h" | 5 #include "base/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/time.h> | 10 #include <sys/time.h> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 base::mac::ScopedCFTypeRef<CFTimeZoneRef> | 73 base::mac::ScopedCFTypeRef<CFTimeZoneRef> |
74 time_zone(is_local ? CFTimeZoneCopySystem() : NULL); | 74 time_zone(is_local ? CFTimeZoneCopySystem() : NULL); |
75 CFAbsoluteTime seconds = CFGregorianDateGetAbsoluteTime(date, time_zone) + | 75 CFAbsoluteTime seconds = CFGregorianDateGetAbsoluteTime(date, time_zone) + |
76 kCFAbsoluteTimeIntervalSince1970; | 76 kCFAbsoluteTimeIntervalSince1970; |
77 return Time(static_cast<int64>(seconds * kMicrosecondsPerSecond) + | 77 return Time(static_cast<int64>(seconds * kMicrosecondsPerSecond) + |
78 kWindowsEpochDeltaMicroseconds); | 78 kWindowsEpochDeltaMicroseconds); |
79 } | 79 } |
80 | 80 |
81 void Time::Explode(bool is_local, Exploded* exploded) const { | 81 void Time::Explode(bool is_local, Exploded* exploded) const { |
82 CFAbsoluteTime seconds = | 82 CFAbsoluteTime seconds = |
83 (static_cast<double>((us_ - kWindowsEpochDeltaMicroseconds) / | 83 ((static_cast<double>(us_) - kWindowsEpochDeltaMicroseconds) / |
84 kMicrosecondsPerSecond) - kCFAbsoluteTimeIntervalSince1970); | 84 kMicrosecondsPerSecond) - kCFAbsoluteTimeIntervalSince1970; |
85 | 85 |
86 base::mac::ScopedCFTypeRef<CFTimeZoneRef> | 86 base::mac::ScopedCFTypeRef<CFTimeZoneRef> |
87 time_zone(is_local ? CFTimeZoneCopySystem() : NULL); | 87 time_zone(is_local ? CFTimeZoneCopySystem() : NULL); |
88 CFGregorianDate date = CFAbsoluteTimeGetGregorianDate(seconds, time_zone); | 88 CFGregorianDate date = CFAbsoluteTimeGetGregorianDate(seconds, time_zone); |
89 | 89 |
90 exploded->year = date.year; | 90 exploded->year = date.year; |
91 exploded->month = date.month; | 91 exploded->month = date.month; |
92 exploded->day_of_month = date.day; | 92 exploded->day_of_month = date.day; |
93 exploded->hour = date.hour; | 93 exploded->hour = date.hour; |
94 exploded->minute = date.minute; | 94 exploded->minute = date.minute; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 return TimeTicks(absolute_micro); | 131 return TimeTicks(absolute_micro); |
132 } | 132 } |
133 | 133 |
134 // static | 134 // static |
135 TimeTicks TimeTicks::HighResNow() { | 135 TimeTicks TimeTicks::HighResNow() { |
136 return Now(); | 136 return Now(); |
137 } | 137 } |
138 | 138 |
139 } // namespace base | 139 } // namespace base |
OLD | NEW |