comctl32/datetime: Always store a recalculated day of week instead of a value passed in (DTM_SETSYSTEMTIME).
This commit is contained in:
parent
99ded940e1
commit
9557376138
|
@ -231,6 +231,7 @@ extern void UPDOWN_Unregister(void);
|
||||||
|
|
||||||
|
|
||||||
int MONTHCAL_MonthLength(int month, int year);
|
int MONTHCAL_MonthLength(int month, int year);
|
||||||
|
int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year);
|
||||||
|
|
||||||
extern void THEMING_Initialize(void);
|
extern void THEMING_Initialize(void);
|
||||||
extern void THEMING_Uninitialize(void);
|
extern void THEMING_Uninitialize(void);
|
||||||
|
|
|
@ -88,6 +88,7 @@ typedef struct
|
||||||
|
|
||||||
/* in monthcal.c */
|
/* in monthcal.c */
|
||||||
extern int MONTHCAL_MonthLength(int month, int year);
|
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
|
/* this list of defines is closely related to `allowedformatchars' defined
|
||||||
* in datetime.c; the high nibble indicates the `base type' of the format
|
* 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 (flag == GDT_VALID) {
|
||||||
if (systime->wYear < 1601 || systime->wYear > 30827 ||
|
if (systime->wYear < 1601 || systime->wYear > 30827 ||
|
||||||
systime->wMonth < 1 || systime->wMonth > 12 ||
|
systime->wMonth < 1 || systime->wMonth > 12 ||
|
||||||
systime->wDayOfWeek > 6 ||
|
|
||||||
systime->wDay < 1 || systime->wDay > 31 ||
|
systime->wDay < 1 || systime->wDay > 31 ||
|
||||||
systime->wHour > 23 ||
|
systime->wHour > 23 ||
|
||||||
systime->wMinute > 59 ||
|
systime->wMinute > 59 ||
|
||||||
systime->wSecond > 59 ||
|
systime->wSecond > 59 ||
|
||||||
systime->wMilliseconds > 999
|
systime->wMilliseconds > 999
|
||||||
)
|
)
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
infoPtr->dateValid = TRUE;
|
infoPtr->dateValid = TRUE;
|
||||||
infoPtr->date = *systime;
|
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->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
|
||||||
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
|
||||||
} else if ((infoPtr->dwStyle & DTS_SHOWNONE) && (flag == GDT_NONE)) {
|
} 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);
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
||||||
return 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) */
|
/* returns the day in the week(0 == sunday, 6 == saturday) */
|
||||||
/* day(1 == 1st, 2 == 2nd... etc), year is the year value */
|
/* 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);
|
year-=(month < 3);
|
||||||
|
|
||||||
|
|
|
@ -616,7 +616,7 @@ static void test_dtm_set_and_get_system_time(void)
|
||||||
st = ref;
|
st = ref;
|
||||||
st.wDayOfWeek = 10;
|
st.wDayOfWeek = 10;
|
||||||
r = SendMessage(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
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);
|
r = SendMessage(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
||||||
expect(GDT_VALID, r);
|
expect(GDT_VALID, r);
|
||||||
expect_systime(&ref, &getSt);
|
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);
|
r = SendMessage(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
||||||
expect(GDT_VALID, r);
|
expect(GDT_VALID, r);
|
||||||
/* 01.10.2009 is Thursday */
|
/* 01.10.2009 is Thursday */
|
||||||
todo_wine expect(4, (LRESULT)getSt.wDayOfWeek);
|
expect(4, (LRESULT)getSt.wDayOfWeek);
|
||||||
st.wDayOfWeek = 4;
|
st.wDayOfWeek = 4;
|
||||||
todo_wine expect_systime(&st, &getSt);
|
expect_systime(&st, &getSt);
|
||||||
|
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue