diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-06-11 16:35:31 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-06-11 16:35:31 +0200 |
commit | 1ae7cdd512a28a973aaa087f4516baca1cae665b (patch) | |
tree | 9853eecd08e3669ba8143cd9c7bb2d0efd7342a5 /src/common/Time/Timezone.cpp | |
parent | 2abf19e83286bdc60765bdc1caf3a78c900e2d99 (diff) |
Core/Common: Update PCH content to include most commonly used headers
Diffstat (limited to 'src/common/Time/Timezone.cpp')
-rw-r--r-- | src/common/Time/Timezone.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/common/Time/Timezone.cpp b/src/common/Time/Timezone.cpp index 5cd80d03232..6c9e58e0c93 100644 --- a/src/common/Time/Timezone.cpp +++ b/src/common/Time/Timezone.cpp @@ -17,13 +17,19 @@ #include "Timezone.h" #include "Hash.h" -#include "Locales.h" #include "MapUtils.h" +#include "Tuples.h" +#include <algorithm> +#include <unordered_map> + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS #include "StringConvert.h" +#else +#include "Locales.h" +#include "Util.h" #include <boost/locale/date_time_facet.hpp> -#include <chrono> #include <memory> -#include <unordered_map> +#endif namespace { @@ -163,20 +169,13 @@ std::string GetSystemZoneName() std::string_view FindClosestClientSupportedTimezone(std::string_view currentTimezone, Minutes currentTimezoneOffset) { // try exact match - auto itr = std::find_if(_clientSupportedTimezones.begin(), _clientSupportedTimezones.end(), [currentTimezone](ClientSupportedTimezone const& tz) - { - return tz.second == currentTimezone; - }); + auto itr = std::ranges::find(_clientSupportedTimezones, currentTimezone, Trinity::TupleElement<1>); if (itr != _clientSupportedTimezones.end()) return itr->second; // try closest offset - itr = std::min_element(_clientSupportedTimezones.begin(), _clientSupportedTimezones.end(), [currentTimezoneOffset](ClientSupportedTimezone const& left, ClientSupportedTimezone const& right) - { - Minutes leftDiff = left.first - currentTimezoneOffset; - Minutes rightDiff = right.first - currentTimezoneOffset; - return std::abs(leftDiff.count()) < std::abs(rightDiff.count()); - }); + itr = std::ranges::min_element(_clientSupportedTimezones, std::ranges::less(), + [currentTimezoneOffset](ClientSupportedTimezone const& ctz) { return std::chrono::abs(ctz.first - currentTimezoneOffset); }); return itr->second; } |