| 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 23 matching lines...) Expand all Loading... |
| 34 const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(0); | 34 const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(0); |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 Time Time::Now() { | 37 Time Time::Now() { |
| 38 CFAbsoluteTime now = | 38 CFAbsoluteTime now = |
| 39 CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970; | 39 CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970; |
| 40 return Time(static_cast<int64>(now * kMicrosecondsPerSecond)); | 40 return Time(static_cast<int64>(now * kMicrosecondsPerSecond)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 Time Time::NowFromSystemTime() { |
| 45 // Just use Now() because Now() returns the system time. |
| 46 return Now(); |
| 47 } |
| 48 |
| 49 // static |
| 44 Time Time::FromExploded(bool is_local, const Exploded& exploded) { | 50 Time Time::FromExploded(bool is_local, const Exploded& exploded) { |
| 45 CFGregorianDate date; | 51 CFGregorianDate date; |
| 46 date.second = exploded.second + | 52 date.second = exploded.second + |
| 47 exploded.millisecond / static_cast<double>(kMillisecondsPerSecond); | 53 exploded.millisecond / static_cast<double>(kMillisecondsPerSecond); |
| 48 date.minute = exploded.minute; | 54 date.minute = exploded.minute; |
| 49 date.hour = exploded.hour; | 55 date.hour = exploded.hour; |
| 50 date.day = exploded.day_of_month; | 56 date.day = exploded.day_of_month; |
| 51 date.month = exploded.month; | 57 date.month = exploded.month; |
| 52 date.year = exploded.year; | 58 date.year = exploded.year; |
| 53 | 59 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 116 |
| 111 return TimeTicks(absolute_micro); | 117 return TimeTicks(absolute_micro); |
| 112 } | 118 } |
| 113 | 119 |
| 114 // static | 120 // static |
| 115 TimeTicks TimeTicks::HighResNow() { | 121 TimeTicks TimeTicks::HighResNow() { |
| 116 return Now(); | 122 return Now(); |
| 117 } | 123 } |
| 118 | 124 |
| 119 } // namespace base | 125 } // namespace base |
| OLD | NEW |