[0.4.14][TIMEDATE] Fix the way the current time-zone is found in the list. (#5649)

port back:
0.4.15-dev-6588-g d9cd760173 [TIMEDATE] Fix the way the current time-zone is found in the list. (#5649)

which fixes regression CORE-18666 'Wrong timezone saved/displayed'
which was introduced by 0.4.14-dev-1522-g aa69236646

no increase in binary size luckily:
timedate.cpl 0.4.14rls RosBEWin2.1.6 GCC4.7.2dbg  368.128 -> 368.128
This commit is contained in:
Joachim Henze 2023-09-09 07:02:12 +02:00
parent d307cdba0e
commit b54a6fe33c

View file

@ -1,12 +1,10 @@
/* /*
* PROJECT: ReactOS Timedate Control Panel * PROJECT: ReactOS Timedate Control Panel
* LICENSE: GPL - See COPYING in the top level directory * LICENSE: GPL - See COPYING in the top level directory
* FILE: dll/cpl/timedate/timezone.c
* PURPOSE: Time Zone property page * PURPOSE: Time Zone property page
* COPYRIGHT: Copyright 2004-2005 Eric Kohl * COPYRIGHT: Copyright 2004-2005 Eric Kohl
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com> * Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
* Copyright 2006 Christoph v. Wittich <Christoph@ActiveVB.de> * Copyright 2006 Christoph v. Wittich <Christoph@ActiveVB.de>
*
*/ */
#include "timedate.h" #include "timedate.h"
@ -168,36 +166,45 @@ ShowTimeZoneList(HWND hwnd)
{ {
TIME_ZONE_INFORMATION TimeZoneInfo; TIME_ZONE_INFORMATION TimeZoneInfo;
PTIMEZONE_ENTRY Entry; PTIMEZONE_ENTRY Entry;
BOOL bDoAdvancedTest; DWORD dwCount;
DWORD dwIndex; DWORD dwIndex = 0;
DWORD i; BOOL bFound = FALSE;
GetTimeZoneInformation(&TimeZoneInfo); if (GetTimeZoneInformation(&TimeZoneInfo) == TIME_ZONE_ID_INVALID)
bDoAdvancedTest = (!*TimeZoneInfo.StandardName); ZeroMemory(&TimeZoneInfo, sizeof(TimeZoneInfo));
dwIndex = 0; for (Entry = TimeZoneListHead; Entry != NULL; Entry = Entry->Next)
i = 0;
Entry = TimeZoneListHead;
while (Entry != NULL)
{ {
SendMessageW(hwnd, dwCount = SendMessageW(hwnd,
CB_ADDSTRING, CB_ADDSTRING,
0, 0,
(LPARAM)Entry->Description); (LPARAM)Entry->Description);
if (dwCount == CB_ERR || dwCount == CB_ERRSPACE)
continue;
if ( (!bDoAdvancedTest && *Entry->StandardName && if (bFound)
wcscmp(Entry->StandardName, TimeZoneInfo.StandardName) == 0) || continue;
( (Entry->TimezoneInfo.Bias == TimeZoneInfo.Bias) &&
(Entry->TimezoneInfo.StandardBias == TimeZoneInfo.StandardBias) && if (*TimeZoneInfo.StandardName && *Entry->StandardName)
(Entry->TimezoneInfo.DaylightBias == TimeZoneInfo.DaylightBias) &&
(memcmp(&Entry->TimezoneInfo.StandardDate, &TimeZoneInfo.StandardDate, sizeof(SYSTEMTIME)) == 0) &&
(memcmp(&Entry->TimezoneInfo.DaylightDate, &TimeZoneInfo.DaylightDate, sizeof(SYSTEMTIME)) == 0) ) )
{ {
dwIndex = i; if (wcscmp(Entry->StandardName, TimeZoneInfo.StandardName) == 0)
{
dwIndex = dwCount;
bFound = TRUE;
}
}
else
{
if ((Entry->TimezoneInfo.Bias == TimeZoneInfo.Bias) &&
(Entry->TimezoneInfo.StandardBias == TimeZoneInfo.StandardBias) &&
(Entry->TimezoneInfo.DaylightBias == TimeZoneInfo.DaylightBias) &&
(memcmp(&Entry->TimezoneInfo.StandardDate, &TimeZoneInfo.StandardDate, sizeof(SYSTEMTIME)) == 0) &&
(memcmp(&Entry->TimezoneInfo.DaylightDate, &TimeZoneInfo.DaylightDate, sizeof(SYSTEMTIME)) == 0))
{
dwIndex = dwCount;
bFound = TRUE;
}
} }
i++;
Entry = Entry->Next;
} }
SendMessageW(hwnd, SendMessageW(hwnd,
@ -285,7 +292,7 @@ TimeZonePageProc(HWND hwndDlg,
case WM_DRAWITEM: case WM_DRAWITEM:
{ {
LPDRAWITEMSTRUCT lpDrawItem; LPDRAWITEMSTRUCT lpDrawItem;
lpDrawItem = (LPDRAWITEMSTRUCT) lParam; lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
if(lpDrawItem->CtlID == IDC_WORLD_BACKGROUND) if(lpDrawItem->CtlID == IDC_WORLD_BACKGROUND)
{ {
HDC hdcMem; HDC hdcMem;