diff options
Diffstat (limited to 'platform')
| -rw-r--r-- | platform/nacl/os_nacl.cpp | 26 | ||||
| -rw-r--r-- | platform/windows/os_windows.cpp | 30 | ||||
| -rw-r--r-- | platform/winrt/os_winrt.cpp | 16 |
3 files changed, 72 insertions, 0 deletions
diff --git a/platform/nacl/os_nacl.cpp b/platform/nacl/os_nacl.cpp index ecace58801..b282209d72 100644 --- a/platform/nacl/os_nacl.cpp +++ b/platform/nacl/os_nacl.cpp @@ -273,6 +273,32 @@ OS::Time OSNacl::get_time(bool utc) const { return ret; }; +OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { + time_t t = time(NULL); + struct tm *lt = localtime(&t); + char name[16]; + strftime(name, 16, "%Z", lt); + name[15] = 0; + TimeZoneInfo ret; + ret.name = name; + + char bias_buf[16]; + strftime(bias_buf, 16, "%z", lt); + int bias; + bias_buf[15] = 0; + sscanf(bias_buf, "%d", &bias); + + // convert from ISO 8601 (1 minute=1, 1 hour=100) to minutes + int hour = (int)bias / 100; + int minutes = bias % 100; + if (bias < 0) + ret.bias = hour * 60 - minutes; + else + ret.bias = hour * 60 + minutes; + + return ret; +}; + void OSNacl::delay_usec(uint32_t p_usec) const { //usleep(p_usec); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 16b9e9b327..cdf9b007d1 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1858,6 +1858,36 @@ OS::Time OS_Windows::get_time(bool utc) 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(bool local) const { diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index a84e54ee0e..24037f05d7 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -469,6 +469,22 @@ OS::Time OSWinrt::get_time(bool utc) const { 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 OSWinrt::get_unix_time(bool utc) const { FILETIME ft; |