diff --git a/CHANGELOG.md b/CHANGELOG.md index 757f94a97..a90fb6a6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +**Fixes**: + +- Correct the timestamp resolution to microseconds on Windows. ([#1039](https://github.com/getsentry/sentry-native/pull/1039)) + ## 0.7.9 **Fixes**: diff --git a/src/sentry_utils.h b/src/sentry_utils.h index 41678d7d4..cbc72898b 100644 --- a/src/sentry_utils.h +++ b/src/sentry_utils.h @@ -106,9 +106,11 @@ sentry__usec_time(void) // Contains a 64-bit value representing the number of 100-nanosecond // intervals since January 1, 1601 (UTC). FILETIME file_time; - SYSTEMTIME system_time; - GetSystemTime(&system_time); - SystemTimeToFileTime(&system_time, &file_time); +# if _WIN32_WINNT >= 0x0602 + GetSystemTimePreciseAsFileTime(&file_time); +# else + GetSystemTimeAsFileTime(&file_time); +# endif uint64_t timestamp = (uint64_t)file_time.dwLowDateTime + ((uint64_t)file_time.dwHighDateTime << 32);