diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index fd071109242..e0d19707bf2 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -231,6 +231,7 @@ extern void UPDOWN_Unregister(void); int MONTHCAL_MonthLength(int month, int year); +int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year); extern void THEMING_Initialize(void); extern void THEMING_Uninitialize(void); diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c index 224519afc58..8f7f5dd46ef 100644 --- a/dlls/comctl32/datetime.c +++ b/dlls/comctl32/datetime.c @@ -88,6 +88,7 @@ typedef struct /* in monthcal.c */ extern int MONTHCAL_MonthLength(int month, int year); +extern int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year); /* this list of defines is closely related to `allowedformatchars' defined * in datetime.c; the high nibble indicates the `base type' of the format @@ -164,17 +165,21 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *sy if (flag == GDT_VALID) { if (systime->wYear < 1601 || systime->wYear > 30827 || systime->wMonth < 1 || systime->wMonth > 12 || - systime->wDayOfWeek > 6 || systime->wDay < 1 || systime->wDay > 31 || systime->wHour > 23 || systime->wMinute > 59 || systime->wSecond > 59 || systime->wMilliseconds > 999 ) - return 0; + return FALSE; infoPtr->dateValid = TRUE; infoPtr->date = *systime; + /* always store a valid day of week */ + infoPtr->date.wDayOfWeek = + MONTHCAL_CalculateDayOfWeek(infoPtr->date.wDay, infoPtr->date.wMonth, + infoPtr->date.wYear); + SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date)); SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); } else if ((infoPtr->dwStyle & DTS_SHOWNONE) && (flag == GDT_NONE)) { @@ -182,7 +187,7 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *sy SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0); } else - return 0; + return FALSE; InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); return TRUE; diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index fcfc7eb998d..71e477e3da1 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -199,7 +199,7 @@ static void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) /* returns the day in the week(0 == sunday, 6 == saturday) */ /* day(1 == 1st, 2 == 2nd... etc), year is the year value */ -static int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year) +int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year) { year-=(month < 3); diff --git a/dlls/comctl32/tests/datetime.c b/dlls/comctl32/tests/datetime.c index 26d7ea10709..c449e45acf2 100644 --- a/dlls/comctl32/tests/datetime.c +++ b/dlls/comctl32/tests/datetime.c @@ -616,7 +616,7 @@ static void test_dtm_set_and_get_system_time(void) st = ref; st.wDayOfWeek = 10; r = SendMessage(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st); - todo_wine expect(1, r); + expect(1, r); r = SendMessage(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt); expect(GDT_VALID, r); expect_systime(&ref, &getSt); @@ -661,9 +661,9 @@ static void test_dtm_set_and_get_system_time(void) r = SendMessage(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt); expect(GDT_VALID, r); /* 01.10.2009 is Thursday */ - todo_wine expect(4, (LRESULT)getSt.wDayOfWeek); + expect(4, (LRESULT)getSt.wDayOfWeek); st.wDayOfWeek = 4; - todo_wine expect_systime(&st, &getSt); + expect_systime(&st, &getSt); DestroyWindow(hWnd); }