From 88998a47b210daa8006844f419f66a4e3dc23e20 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 16 Jun 2022 12:57:05 +0300 Subject: fix for processing our own time zones --- include/m_timezones.h | 12 ++++++------ plugins/UserInfoEx/src/ctrl_tzcombo.cpp | 10 +++++----- src/mir_core/src/Windows/timezones.cpp | 5 +++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/m_timezones.h b/include/m_timezones.h index 4f4d49ca2b..5fc78c41d0 100644 --- a/include/m_timezones.h +++ b/include/m_timezones.h @@ -77,20 +77,20 @@ __forceinline int printTimeStampByContact(MCONTACT hContact, mir_time ts, LPCTST } #ifdef _MSC_VER -__forceinline LPTIME_ZONE_INFORMATION getTziByContact(MCONTACT hContact) +__forceinline LPTIME_ZONE_INFORMATION getTziByContact(MCONTACT hContact, uint32_t dwFlags = 0) { - return TimeZone_GetInfo(TimeZone_CreateByContact(hContact, nullptr, 0)); + return TimeZone_GetInfo(TimeZone_CreateByContact(hContact, nullptr, dwFlags)); } -__forceinline int getTimeZoneTimeByContact(MCONTACT hContact, SYSTEMTIME *st) +__forceinline int getTimeZoneTimeByContact(MCONTACT hContact, SYSTEMTIME *st, uint32_t dwFlags = 0) { - return TimeZone_GetTimeZoneTime(TimeZone_CreateByContact(hContact, nullptr, 0), st); + return TimeZone_GetTimeZoneTime(TimeZone_CreateByContact(hContact, nullptr, dwFlags), st); } #endif -__forceinline mir_time timeStampToTimeZoneTimeStampByContact(MCONTACT hContact, mir_time ts) +__forceinline mir_time timeStampToTimeZoneTimeStampByContact(MCONTACT hContact, mir_time ts, uint32_t dwFlags = 0) { - return TimeZone_UtcToLocal(TimeZone_CreateByContact(hContact, nullptr, 0), ts); + return TimeZone_UtcToLocal(TimeZone_CreateByContact(hContact, nullptr, dwFlags), ts); } #endif diff --git a/plugins/UserInfoEx/src/ctrl_tzcombo.cpp b/plugins/UserInfoEx/src/ctrl_tzcombo.cpp index f28c7812a0..dd6c8d8d49 100644 --- a/plugins/UserInfoEx/src/ctrl_tzcombo.cpp +++ b/plugins/UserInfoEx/src/ctrl_tzcombo.cpp @@ -75,12 +75,12 @@ CTzCombo::CTzCombo(HWND hDlg, uint16_t idCtrl, LPCSTR pszSetting) **/ int CTzCombo::Find(LPTIME_ZONE_INFORMATION pTimeZone) const { - int nItemIndex; int nItemCount = ComboBox_GetCount(_hwnd); - for (nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++) { - if (pTimeZone == TimeZone_GetInfo((HANDLE)ComboBox_GetItemData(_hwnd, nItemIndex))) - return nItemIndex; + for (int i = 0; i < nItemCount; i++) { + HANDLE pItemData = (HANDLE)ComboBox_GetItemData(_hwnd, i); + if (pItemData && pTimeZone == TimeZone_GetInfo(pItemData)) + return i; } return CB_ERR; } @@ -110,7 +110,7 @@ BOOL CTzCombo::OnInfoChanged(MCONTACT hContact, LPCSTR) { if (!_Flags.B.hasChanged) { LPTIME_ZONE_INFORMATION pTimeZone; - pTimeZone = getTziByContact(hContact); + pTimeZone = getTziByContact(hContact, TZF_PLF_CB); ComboBox_SetCurSel(_hwnd, Find(pTimeZone)); _curSel = ComboBox_GetCurSel(_hwnd); SendMessage(GetParent(_hwnd), WM_TIMER, 0, 0); diff --git a/src/mir_core/src/Windows/timezones.cpp b/src/mir_core/src/Windows/timezones.cpp index 414e59ff91..63d026a3eb 100644 --- a/src/mir_core/src/Windows/timezones.cpp +++ b/src/mir_core/src/Windows/timezones.cpp @@ -216,8 +216,9 @@ MIR_CORE_DLL(HANDLE) TimeZone_CreateByName(LPCTSTR tszName, uint32_t dwFlags) if (tszName == nullptr) return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? nullptr : &myInfo.myTZ; - if (mir_wstrcmp(myInfo.myTZ.tszName, tszName) == 0) - return (dwFlags & TZF_DIFONLY) ? nullptr : &myInfo.myTZ; + if (!(dwFlags & TZF_PLF_CB)) + if (mir_wstrcmp(myInfo.myTZ.tszName, tszName) == 0) + return (dwFlags & TZF_DIFONLY) ? nullptr : &myInfo.myTZ; MIM_TIMEZONE tzsearch; tzsearch.hash = mir_hashstrT(tszName); -- cgit v1.2.3