aboutsummaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-06-07 00:32:29 -0300
committerJuan Linietsky2015-06-07 00:32:29 -0300
commit8d6181729381ff4b06b754f1c491666f70c77a6e (patch)
tree45aa290cc13c9758ee9f95c02e162035756c0b5c /platform/windows/os_windows.cpp
parentefbe877005295995c6c24659d75800616e5da945 (diff)
parentc5338fd6c40d08472b680809cfa04d47826bdcf5 (diff)
downloadgodot-8d6181729381ff4b06b754f1c491666f70c77a6e.tar.gz
godot-8d6181729381ff4b06b754f1c491666f70c77a6e.tar.zst
godot-8d6181729381ff4b06b754f1c491666f70c77a6e.zip
Merge pull request #2037 from est31/use-local-win
Time zone support
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 4e8f9fcd9..cdf9b007d 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1832,7 +1832,10 @@ String OS_Windows::get_name() {
OS::Date OS_Windows::get_date() const {
SYSTEMTIME systemtime;
- GetSystemTime(&systemtime);
+ if (local)
+ GetSystemTime(&systemtime);
+ else
+ GetLocalTime(&systemtime);
Date date;
date.day=systemtime.wDay;
date.month=Month(systemtime.wMonth);
@@ -1841,10 +1844,13 @@ OS::Date OS_Windows::get_date() const {
date.dst=false;
return date;
}
-OS::Time OS_Windows::get_time() const {
+OS::Time OS_Windows::get_time(bool utc) const {
SYSTEMTIME systemtime;
- GetLocalTime(&systemtime);
+ if (utc)
+ GetSystemTime(&systemtime);
+ else
+ GetLocalTime(&systemtime);
Time time;
time.hour=systemtime.wHour;
@@ -1852,8 +1858,38 @@ OS::Time OS_Windows::get_time() const {
time.sec=systemtime.wSecond;
return time;
}
+OS::Time OS_Windows::get_time(bool utc) const {
+
+ SYSTEMTIME systemtime;
+ if (utc)
+ GetSystemTime(&systemtime);
+ else
+ GetLocalTime(&systemtime);
+
+ Time time;
+ time.hour=systemtime.wHour;
+ time.min=systemtime.wMinute;
+ time.sec=systemtime.wSecond;
+ return time;
+}
+
+OS::TimeZoneInfo OS_Windows::get_time_zone_info() const {
+ TIME_ZONE_INFORMATION info;
+ bool daylight = false;
+ if (GetTimeZoneInformation(info) == TIME_ZONE_ID_DAYLIGHT)
+ daylight = true;
+
+ if (daylight) {
+ ret.name = info.DaylightName;
+ } else {
+ ret.name = info.StandardName;
+ }
+
+ ret.bias = info.Bias;
+ return ret;
+}
-uint64_t OS_Windows::get_unix_time() const {
+uint64_t OS_Windows::get_unix_time(bool local) const {
FILETIME ft;
SYSTEMTIME st;