1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Fix Time.get_unix_time_from_system() not including msecs

This commit is contained in:
Haoyu Qiu
2022-08-08 17:45:32 +08:00
parent 5b4e7a0693
commit 1be078ebcb
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;