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 /drivers/unix/os_unix.cpp | |
parent | 3a82a1315b31221507808a540d8657af835f27ca (diff) | |
parent | 0aecfc92540618508568b5c7e8a050d36cf5322b (diff) | |
download | redot-engine-ff824b6f9d5bfa021ff788731a7e135afc95accd.tar.gz |
Merge pull request #65509 from gotnospirit/master-os-get_datetime
get_datetime_* functions can return wrong values
Diffstat (limited to 'drivers/unix/os_unix.cpp')
-rw-r--r-- | drivers/unix/os_unix.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 384f46c8df..beb2812999 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -200,7 +200,7 @@ double OS_Unix::get_unix_time() const { return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000; } -OS::Date OS_Unix::get_date(bool p_utc) const { +OS::DateTime OS_Unix::get_datetime(bool p_utc) const { time_t t = time(nullptr); struct tm lt; if (p_utc) { @@ -208,7 +208,7 @@ OS::Date OS_Unix::get_date(bool p_utc) const { } else { localtime_r(&t, <); } - Date ret; + DateTime ret; ret.year = 1900 + lt.tm_year; // Index starting at 1 to match OS_Unix::get_date // and Windows SYSTEMTIME and tm_mon follows the typical structure @@ -216,24 +216,11 @@ OS::Date OS_Unix::get_date(bool p_utc) const { ret.month = (Month)(lt.tm_mon + 1); ret.day = lt.tm_mday; ret.weekday = (Weekday)lt.tm_wday; - ret.dst = lt.tm_isdst; - - return ret; -} - -OS::Time OS_Unix::get_time(bool p_utc) const { - time_t t = time(nullptr); - struct tm lt; - if (p_utc) { - gmtime_r(&t, <); - } else { - localtime_r(&t, <); - } - Time ret; ret.hour = lt.tm_hour; ret.minute = lt.tm_min; ret.second = lt.tm_sec; - get_time_zone_info(); + ret.dst = lt.tm_isdst; + return ret; } |