From 070cd23b6cf2e985713b90455cb7f7c53535cbcf Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 21 Nov 2023 12:25:22 +0100 Subject: Core/Calendar: Implement different timezone support for ingame calendar Closes #8390 Closes #29427 (cherry picked from commit b888b1b09f71a8b8b4a9d45c804a1f164fb65ac3) --- src/common/Utilities/Util.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/common/Utilities/Util.cpp') diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index ac97e724902..d852ed655a0 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -58,9 +58,20 @@ std::vector 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); -- cgit v1.2.3