| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 #ifdef OS_MACOSX | 7 #ifdef OS_MACOSX |
| 8 #include <mach/mach_time.h> | 8 #include <mach/mach_time.h> |
| 9 #endif | 9 #endif |
| 10 #include <sys/time.h> | 10 #include <sys/time.h> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 struct timezone tz = { 0, 0 }; // UTC | 34 struct timezone tz = { 0, 0 }; // UTC |
| 35 if (gettimeofday(&tv, &tz) != 0) { | 35 if (gettimeofday(&tv, &tz) != 0) { |
| 36 DCHECK(0) << "Could not determine time of day"; | 36 DCHECK(0) << "Could not determine time of day"; |
| 37 } | 37 } |
| 38 // Combine seconds and microseconds in a 64-bit field containing microseconds | 38 // Combine seconds and microseconds in a 64-bit field containing microseconds |
| 39 // since the epoch. That's enough for nearly 600 centuries. | 39 // since the epoch. That's enough for nearly 600 centuries. |
| 40 return tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec; | 40 return tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec; |
| 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 struct tm timestruct; | 51 struct tm timestruct; |
| 46 timestruct.tm_sec = exploded.second; | 52 timestruct.tm_sec = exploded.second; |
| 47 timestruct.tm_min = exploded.minute; | 53 timestruct.tm_min = exploded.minute; |
| 48 timestruct.tm_hour = exploded.hour; | 54 timestruct.tm_hour = exploded.hour; |
| 49 timestruct.tm_mday = exploded.day_of_month; | 55 timestruct.tm_mday = exploded.day_of_month; |
| 50 timestruct.tm_mon = exploded.month - 1; | 56 timestruct.tm_mon = exploded.month - 1; |
| 51 timestruct.tm_year = exploded.year - 1900; | 57 timestruct.tm_year = exploded.year - 1900; |
| 52 timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this | 58 timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this |
| 53 timestruct.tm_yday = 0; // mktime/timegm ignore this | 59 timestruct.tm_yday = 0; // mktime/timegm ignore this |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 175 |
| 170 return TimeTicks(absolute_micro); | 176 return TimeTicks(absolute_micro); |
| 171 } | 177 } |
| 172 | 178 |
| 173 // static | 179 // static |
| 174 TimeTicks TimeTicks::HighResNow() { | 180 TimeTicks TimeTicks::HighResNow() { |
| 175 return Now(); | 181 return Now(); |
| 176 } | 182 } |
| 177 | 183 |
| 178 } // namespace base | 184 } // namespace base |
| OLD | NEW |