| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <sys/time.h> | 7 #include <sys/time.h> |
| 8 #include <time.h> | 8 #include <time.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 struct tm timestruct; | 103 struct tm timestruct; |
| 104 timestruct.tm_sec = exploded.second; | 104 timestruct.tm_sec = exploded.second; |
| 105 timestruct.tm_min = exploded.minute; | 105 timestruct.tm_min = exploded.minute; |
| 106 timestruct.tm_hour = exploded.hour; | 106 timestruct.tm_hour = exploded.hour; |
| 107 timestruct.tm_mday = exploded.day_of_month; | 107 timestruct.tm_mday = exploded.day_of_month; |
| 108 timestruct.tm_mon = exploded.month - 1; | 108 timestruct.tm_mon = exploded.month - 1; |
| 109 timestruct.tm_year = exploded.year - 1900; | 109 timestruct.tm_year = exploded.year - 1900; |
| 110 timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this | 110 timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this |
| 111 timestruct.tm_yday = 0; // mktime/timegm ignore this | 111 timestruct.tm_yday = 0; // mktime/timegm ignore this |
| 112 timestruct.tm_isdst = -1; // attempt to figure it out | 112 timestruct.tm_isdst = -1; // attempt to figure it out |
| 113 #if !defined(OS_NACL) | 113 #if !defined(OS_NACL) && !defined(OS_SOLARIS) |
| 114 timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore | 114 timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore |
| 115 timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore | 115 timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore |
| 116 #endif | 116 #endif |
| 117 | 117 |
| 118 time_t seconds; | 118 time_t seconds; |
| 119 if (is_local) | 119 if (is_local) |
| 120 seconds = mktime(×truct); | 120 seconds = mktime(×truct); |
| 121 else | 121 else |
| 122 seconds = timegm(×truct); | 122 seconds = timegm(×truct); |
| 123 | 123 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 struct timeval Time::ToTimeVal() const { | 205 struct timeval Time::ToTimeVal() const { |
| 206 struct timeval result; | 206 struct timeval result; |
| 207 int64 us = us_ - kTimeTToMicrosecondsOffset; | 207 int64 us = us_ - kTimeTToMicrosecondsOffset; |
| 208 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 208 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 209 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 209 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 210 return result; | 210 return result; |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace base | 213 } // namespace base |
| OLD | NEW |