diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-13 11:01:12 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-13 11:01:12 +0200 |
commit | ff824b6f9d5bfa021ff788731a7e135afc95accd (patch) | |
tree | dc5a0174dfe884a8102ddb4c5785fc04be24783e /platform/windows | |
parent | 3a82a1315b31221507808a540d8657af835f27ca (diff) | |
parent | 0aecfc92540618508568b5c7e8a050d36cf5322b (diff) |
Merge pull request #65509 from gotnospirit/master-os-get_datetime
get_datetime_* functions can return wrong values
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/os_windows.cpp | 34 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 3 |
2 files changed, 12 insertions, 25 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index b7794bbbf8..2c268ff3d5 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -290,7 +290,7 @@ String OS_Windows::get_name() const { return "Windows"; } -OS::Date OS_Windows::get_date(bool p_utc) const { +OS::DateTime OS_Windows::get_datetime(bool p_utc) const { SYSTEMTIME systemtime; if (p_utc) { GetSystemTime(&systemtime); @@ -305,28 +305,16 @@ OS::Date OS_Windows::get_date(bool p_utc) const { daylight = true; } - Date date; - date.day = systemtime.wDay; - date.month = Month(systemtime.wMonth); - date.weekday = Weekday(systemtime.wDayOfWeek); - date.year = systemtime.wYear; - date.dst = daylight; - return date; -} - -OS::Time OS_Windows::get_time(bool p_utc) const { - SYSTEMTIME systemtime; - if (p_utc) { - GetSystemTime(&systemtime); - } else { - GetLocalTime(&systemtime); - } - - Time time; - time.hour = systemtime.wHour; - time.minute = systemtime.wMinute; - time.second = systemtime.wSecond; - return time; + DateTime dt; + dt.year = systemtime.wYear; + dt.month = Month(systemtime.wMonth); + dt.day = systemtime.wDay; + dt.weekday = Weekday(systemtime.wDayOfWeek); + dt.hour = systemtime.wHour; + dt.minute = systemtime.wMinute; + dt.second = systemtime.wSecond; + dt.dst = daylight; + return dt; } OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 3e054c068c..53451b780e 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -146,8 +146,7 @@ public: virtual void initialize_joypads() override {} - virtual Date get_date(bool p_utc) const override; - virtual Time get_time(bool p_utc) const override; + virtual DateTime get_datetime(bool p_utc) const override; virtual TimeZoneInfo get_time_zone_info() const override; virtual double get_unix_time() const override; |