diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index fba3e7ca095..f9512379718 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -494,8 +494,8 @@ uint64_t _OS::get_unix_time() const { return OS::get_singleton()->get_unix_time(); }; -uint64_t _OS::get_system_time_msec() const { - return OS::get_singleton()->get_system_time_msec(); +uint64_t _OS::get_system_time_secs() const { + return OS::get_singleton()->get_system_time_secs(); } void _OS::delay_usec(uint32_t p_usec) const { @@ -810,7 +810,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info); ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time); - ObjectTypeDB::bind_method(_MD("get_system_time_msec"), &_OS::get_system_time_msec); + ObjectTypeDB::bind_method(_MD("get_system_time_secs"), &_OS::get_system_time_secs); ObjectTypeDB::bind_method(_MD("set_icon","icon"),&_OS::set_icon); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 8ab88781194..62572d7761e 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -208,7 +208,7 @@ public: Dictionary get_time(bool utc) const; Dictionary get_time_zone_info() const; uint64_t get_unix_time() const; - uint64_t get_system_time_msec() const; + uint64_t get_system_time_secs() const; int get_static_memory_usage() const; int get_static_memory_peak_usage() const; diff --git a/core/os/os.cpp b/core/os/os.cpp index eb5f91167a2..1a505fb2366 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -50,7 +50,7 @@ uint64_t OS::get_unix_time() const { return 0; }; -uint64_t OS::get_system_time_msec() const { +uint64_t OS::get_system_time_secs() const { return 0; } void OS::debug_break() { diff --git a/core/os/os.h b/core/os/os.h index 94cb1d4ea47..711743f23a1 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -256,7 +256,7 @@ public: virtual Time get_time(bool local=false) const=0; virtual TimeZoneInfo get_time_zone_info() const=0; virtual uint64_t get_unix_time() const; - virtual uint64_t get_system_time_msec() const; + virtual uint64_t get_system_time_secs() const; virtual void delay_usec(uint32_t p_usec) const=0; virtual uint64_t get_ticks_usec() const=0; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index bdf7daf7990..405d84f0f1b 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -233,13 +233,12 @@ uint64_t OS_Unix::get_unix_time() const { return time(NULL); }; -uint64_t OS_Unix::get_system_time_msec() const { +uint64_t OS_Unix::get_system_time_secs() const { struct timeval tv_now; gettimeofday(&tv_now, NULL); //localtime(&tv_now.tv_usec); //localtime((const long *)&tv_now.tv_usec); - uint64_t msec = uint64_t(tv_now.tv_sec)*1000+tv_now.tv_usec/1000; - return msec; + return uint64_t(tv_now.tv_sec); } diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 1baed9e869c..a889bba0ffa 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -95,7 +95,7 @@ public: virtual TimeZoneInfo get_time_zone_info() const; virtual uint64_t get_unix_time() const; - virtual uint64_t get_system_time_msec() const; + virtual uint64_t get_system_time_secs() const; virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 95bfa2ea941..6ac27b7dbf9 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1681,10 +1681,16 @@ uint64_t OS_Windows::get_unix_time() const { return (*(uint64_t*)&ft - *(uint64_t*)&fep) / 10000000; }; -uint64_t OS_Windows::get_system_time_msec() const { +uint64_t OS_Windows::get_system_time_secs() const { SYSTEMTIME st; GetSystemTime(&st); - return st.wMilliseconds; + FILETIME ft; + SystemTimeToFileTime(&st,&ft); + uint64_t ret; + ret=ft.dwHighDateTime; + ret<<=32; + ret|=ft.dwLowDateTime; + return ret; } void OS_Windows::delay_usec(uint32_t p_usec) const { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index dfa2b40595c..69bdcda2783 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -231,7 +231,7 @@ public: virtual Time get_time(bool utc) const; virtual TimeZoneInfo get_time_zone_info() const; virtual uint64_t get_unix_time() const; - virtual uint64_t get_system_time_msec() const; + virtual uint64_t get_system_time_secs() const; virtual bool can_draw() const; virtual Error set_cwd(const String& p_cwd);