1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Fix Time.get_unix_time_from_system() not including msecs

(cherry picked from commit 1be078ebcb)
This commit is contained in:
Haoyu Qiu
2022-08-08 17:45:32 +08:00
committed by Rémi Verschelde
parent e44c18ecc0
commit 1ea8b9d2b7
10 changed files with 49 additions and 1 deletions

View File

@@ -549,6 +549,23 @@ uint64_t OS_UWP::get_unix_time() const {
return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000;
};
double OS_UWP::get_subsecond_unix_time() const {
// 1 Windows tick is 100ns
const uint64_t WINDOWS_TICKS_PER_SECOND = 10000000;
const uint64_t TICKS_TO_UNIX_EPOCH = 116444736000000000LL;
SYSTEMTIME st;
GetSystemTime(&st);
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
uint64_t ticks_time;
ticks_time = ft.dwHighDateTime;
ticks_time <<= 32;
ticks_time |= ft.dwLowDateTime;
return (double)(ticks_time - TICKS_TO_UNIX_EPOCH) / WINDOWS_TICKS_PER_SECOND;
}
void OS_UWP::delay_usec(uint32_t p_usec) const {
int msec = p_usec < 1000 ? 1 : p_usec / 1000;