Commit 95573761 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/datetime: Always store a recalculated day of week instead of a value…

comctl32/datetime: Always store a recalculated day of week instead of a value passed in (DTM_SETSYSTEMTIME).
parent 99ded940
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment