OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 5 |
6 // Windows Timer Primer | 6 // Windows Timer Primer |
7 // | 7 // |
8 // A good article: http://www.ddj.com/windows/184416651 | 8 // A good article: http://www.ddj.com/windows/184416651 |
9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 | 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 |
10 // | 10 // |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return; | 244 return; |
245 } | 245 } |
246 | 246 |
247 // FILETIME in UTC. | 247 // FILETIME in UTC. |
248 FILETIME utc_ft; | 248 FILETIME utc_ft; |
249 MicrosecondsToFileTime(us_, &utc_ft); | 249 MicrosecondsToFileTime(us_, &utc_ft); |
250 | 250 |
251 // FILETIME in local time if necessary. | 251 // FILETIME in local time if necessary. |
252 bool success = true; | 252 bool success = true; |
253 // FILETIME in SYSTEMTIME (exploded). | 253 // FILETIME in SYSTEMTIME (exploded). |
254 SYSTEMTIME st; | 254 SYSTEMTIME st = {0}; |
255 if (is_local) { | 255 if (is_local) { |
256 SYSTEMTIME utc_st; | 256 SYSTEMTIME utc_st; |
257 // We don't use FileTimeToLocalFileTime here, since it uses the current | 257 // We don't use FileTimeToLocalFileTime here, since it uses the current |
258 // settings for the time zone and daylight saving time. Therefore, if it is | 258 // settings for the time zone and daylight saving time. Therefore, if it is |
259 // daylight saving time, it will take daylight saving time into account, | 259 // daylight saving time, it will take daylight saving time into account, |
260 // even if the time you are converting is in standard time. | 260 // even if the time you are converting is in standard time. |
261 success = FileTimeToSystemTime(&utc_ft, &utc_st) && | 261 success = FileTimeToSystemTime(&utc_ft, &utc_st) && |
262 SystemTimeToTzSpecificLocalTime(NULL, &utc_st, &st); | 262 SystemTimeToTzSpecificLocalTime(NULL, &utc_st, &st); |
263 } else { | 263 } else { |
264 success = !!FileTimeToSystemTime(&utc_ft, &st); | 264 success = !!FileTimeToSystemTime(&utc_ft, &st); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime()); | 527 return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime()); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 // TimeDelta ------------------------------------------------------------------ | 531 // TimeDelta ------------------------------------------------------------------ |
532 | 532 |
533 // static | 533 // static |
534 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 534 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
535 return TimeDelta(GetHighResNowSingleton()->QPCValueToMicroseconds(qpc_value)); | 535 return TimeDelta(GetHighResNowSingleton()->QPCValueToMicroseconds(qpc_value)); |
536 } | 536 } |
OLD | NEW |