aboutsummaryrefslogtreecommitdiff
path: root/src/common/Time/Timezone.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-11-24 20:01:17 +0100
committerShauren <shauren.trinity@gmail.com>2023-12-02 15:57:09 +0100
commit7be101ac672c904a65e8ac41e04bbddfd19266a7 (patch)
tree9b0d98966a8e4dbade441764d81c53b363184ad4 /src/common/Time/Timezone.cpp
parent45a5b6a9f04d2f605e7141b8da6e9cfa24711e07 (diff)
Core/Locales: Set active code page and locale used by c string functions to utf8
Closes #29455 (cherry picked from commit b299902881cb6525b5a6cc08c5721c0c1c7401ab)
Diffstat (limited to 'src/common/Time/Timezone.cpp')
-rw-r--r--src/common/Time/Timezone.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/common/Time/Timezone.cpp b/src/common/Time/Timezone.cpp
index 6bc5773edc3..9748078fe9f 100644
--- a/src/common/Time/Timezone.cpp
+++ b/src/common/Time/Timezone.cpp
@@ -17,12 +17,13 @@
#include "Timezone.h"
#include "Hash.h"
+#include "Locales.h"
#include "MapUtils.h"
#include "StringConvert.h"
#include "Util.h"
#include <boost/locale/date_time_facet.hpp>
-#include <boost/locale/generator.hpp>
#include <chrono>
+#include <memory>
#include <unordered_map>
namespace
@@ -96,7 +97,11 @@ std::unordered_map<uint32, Minutes, std::identity> InitTimezoneHashDb()
return hashToOffset;
}
-std::unordered_map<uint32, Minutes, std::identity> const _timezoneOffsetsByHash = InitTimezoneHashDb();
+std::unordered_map<uint32, Minutes, std::identity> const& GetTimezoneOffsetsByHash()
+{
+ static std::unordered_map<uint32, Minutes, std::identity> timezoneMap = InitTimezoneHashDb();
+ return timezoneMap;
+}
using ClientSupportedTimezone = std::pair<Minutes, std::string>;
std::array<ClientSupportedTimezone, 11> const _clientSupportedTimezones =
@@ -119,7 +124,7 @@ namespace Trinity::Timezone
{
Minutes GetOffsetByHash(uint32 hash)
{
- if (Minutes const* offset = Containers::MapGetValuePtr(_timezoneOffsetsByHash, hash))
+ if (Minutes const* offset = Containers::MapGetValuePtr(GetTimezoneOffsetsByHash(), hash))
return *offset;
return 0min;
@@ -151,8 +156,7 @@ std::string GetSystemZoneName()
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
return std::string(std::chrono::current_zone()->name());
#else
- static std::locale calendarLocale = boost::locale::generator().generate("");
- std::unique_ptr<boost::locale::abstract_calendar> p(std::use_facet<class boost::locale::calendar_facet>(calendarLocale).create_calendar());
+ std::unique_ptr<boost::locale::abstract_calendar> p(std::use_facet<class boost::locale::calendar_facet>(Locale::GetCalendarLocale()).create_calendar());
return p->get_timezone();
#endif
}