diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-11-21 12:25:22 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-12-02 15:57:03 +0100 |
commit | 45a5b6a9f04d2f605e7141b8da6e9cfa24711e07 (patch) | |
tree | 5d0f5890d888610ad4cf598db9c47e831a41eb35 /src/common/Utilities/Util.cpp | |
parent | 9daaa99ed49fc4ed63007bc932a411d33b5b7ef8 (diff) |
Core/Calendar: Implement different timezone support for ingame calendar
Closes #8390
Closes #29427
(cherry picked from commit b888b1b09f71a8b8b4a9d45c804a1f164fb65ac3)
Diffstat (limited to 'src/common/Utilities/Util.cpp')
-rw-r--r-- | src/common/Utilities/Util.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 9c77e9f9821..8ca639ba6a4 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -58,9 +58,20 @@ std::vector<std::string_view> Trinity::Tokenize(std::string_view str, char sep, #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) struct tm* localtime_r(time_t const* time, struct tm *result) { - localtime_s(result, time); + if (localtime_s(result, time) != 0) + return nullptr; return result; } +struct tm* gmtime_r(time_t const* time, struct tm* result) +{ + if (gmtime_s(result, time) != 0) + return nullptr; + return result; +} +time_t timegm(struct tm* tm) +{ + return _mkgmtime(tm); +} #endif tm TimeBreakdown(time_t time) @@ -70,17 +81,6 @@ tm TimeBreakdown(time_t time) return timeLocal; } -time_t LocalTimeToUTCTime(time_t time) -{ -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) - return time + _timezone; -#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - return timegm(gmtime(&time)); -#else - return time + timezone; -#endif -} - time_t GetLocalHourTimestamp(time_t time, uint8 hour, bool onlyAfterTime) { tm timeLocal = TimeBreakdown(time); |