From 5600316c9f69d2afda82ae0e632715b420dfd402 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Fri, 19 Apr 2019 23:45:07 +0200 Subject: Core/Calendar: Improve calendar timezone handling Improve calendar timezone handling by at least creating events with the correct time if both client and server are in the same timezone. There is currently no information received from the client about in which timezone it is. (cherry picked from commit b33934f6ce9b0227597c712dd6a76b7ed49deea3) --- src/common/Utilities/Util.cpp | 9 +++++++++ src/common/Utilities/Util.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/common') diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index f787edd13ea..5123636f6a0 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -77,6 +77,15 @@ struct tm* localtime_r(time_t const* time, struct tm *result) } #endif +time_t LocalTimeToUTCTime(time_t time) +{ +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) + return time + _timezone; +#else + return time + timezone; +#endif +} + std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly) { uint64 secs = timeInSecs % MINUTE; diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index a858a44b556..1ed9c344765 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -59,6 +59,7 @@ private: TC_COMMON_API int64 MoneyStringToMoney(std::string const& moneyString); TC_COMMON_API struct tm* localtime_r(time_t const* time, struct tm *result); +TC_COMMON_API time_t LocalTimeToUTCTime(time_t time); TC_COMMON_API std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false); TC_COMMON_API uint32 TimeStringToSecs(std::string const& timestring); -- cgit v1.2.3