| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 ticks = now + (num_wrap_timegettime << 32); | 73 ticks = now + (num_wrap_timegettime << 32); |
| 74 // TODO: Calculate with nanosecond precision. Otherwise, we're just | 74 // TODO: Calculate with nanosecond precision. Otherwise, we're just |
| 75 // wasting a multiply and divide when doing Time() on Windows. | 75 // wasting a multiply and divide when doing Time() on Windows. |
| 76 ticks = ticks * kNumNanosecsPerMillisec; | 76 ticks = ticks * kNumNanosecsPerMillisec; |
| 77 #else | 77 #else |
| 78 #error Unsupported platform. | 78 #error Unsupported platform. |
| 79 #endif | 79 #endif |
| 80 return ticks; | 80 return ticks; |
| 81 } | 81 } |
| 82 | 82 |
| 83 uint32_t Time() { | 83 uint32_t Time32() { |
| 84 return static_cast<uint32_t>(TimeNanos() / kNumNanosecsPerMillisec); | 84 return static_cast<uint32_t>(TimeNanos() / kNumNanosecsPerMillisec); |
| 85 } | 85 } |
| 86 | 86 |
| 87 int64_t Time64() { |
| 88 return static_cast<int64_t>(TimeNanos() / kNumNanosecsPerMillisec); |
| 89 } |
| 90 |
| 87 uint64_t TimeMicros() { | 91 uint64_t TimeMicros() { |
| 88 return static_cast<uint64_t>(TimeNanos() / kNumNanosecsPerMicrosec); | 92 return static_cast<uint64_t>(TimeNanos() / kNumNanosecsPerMicrosec); |
| 89 } | 93 } |
| 90 | 94 |
| 91 #if defined(WEBRTC_WIN) | 95 #if defined(WEBRTC_WIN) |
| 92 static const uint64_t kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL; | 96 static const uint64_t kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL; |
| 93 | 97 |
| 94 struct timeval { | 98 struct timeval { |
| 95 long tv_sec, tv_usec; // NOLINT | 99 long tv_sec, tv_usec; // NOLINT |
| 96 }; | 100 }; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } else { | 189 } else { |
| 186 if (later <= earlier) { | 190 if (later <= earlier) { |
| 187 return -static_cast<long>(earlier - later); | 191 return -static_cast<long>(earlier - later); |
| 188 } else { | 192 } else { |
| 189 return -static_cast<long>(earlier + (UINT32_MAX - later) + 1); | 193 return -static_cast<long>(earlier + (UINT32_MAX - later) + 1); |
| 190 } | 194 } |
| 191 } | 195 } |
| 192 #endif | 196 #endif |
| 193 } | 197 } |
| 194 | 198 |
| 199 int64_t TimeDiff64(int64_t later, int64_t earlier) { |
| 200 return later - earlier; |
| 201 } |
| 202 |
| 195 TimestampWrapAroundHandler::TimestampWrapAroundHandler() | 203 TimestampWrapAroundHandler::TimestampWrapAroundHandler() |
| 196 : last_ts_(0), num_wrap_(-1) {} | 204 : last_ts_(0), num_wrap_(-1) {} |
| 197 | 205 |
| 198 int64_t TimestampWrapAroundHandler::Unwrap(uint32_t ts) { | 206 int64_t TimestampWrapAroundHandler::Unwrap(uint32_t ts) { |
| 199 if (num_wrap_ == -1) { | 207 if (num_wrap_ == -1) { |
| 200 last_ts_ = ts; | 208 last_ts_ = ts; |
| 201 num_wrap_ = 0; | 209 num_wrap_ = 0; |
| 202 return ts; | 210 return ts; |
| 203 } | 211 } |
| 204 | 212 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. | 260 if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. |
| 253 day -= 1; | 261 day -= 1; |
| 254 | 262 |
| 255 // Combine all variables into seconds from 1970-01-01 00:00 (except |month| | 263 // Combine all variables into seconds from 1970-01-01 00:00 (except |month| |
| 256 // which was accumulated into |day| above). | 264 // which was accumulated into |day| above). |
| 257 return (((static_cast<int64_t> | 265 return (((static_cast<int64_t> |
| 258 (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; | 266 (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; |
| 259 } | 267 } |
| 260 | 268 |
| 261 } // namespace rtc | 269 } // namespace rtc |
| OLD | NEW |