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

comctl32/monthcal: Handle September 1752 with a special case - it's a 19 day month.

parent a00c217c
......@@ -184,6 +184,9 @@ int MONTHCAL_MonthLength(int month, int year)
else if(month == 13)
month = 1;
/* special case for calendar transition year */
if(month == min_allowed_date.wMonth && year == min_allowed_date.wYear) return 19;
/* if we have a leap year add 1 day to February */
/* a leap year is a year either divisible by 400 */
/* or divisible by 4 and not by 100 */
......@@ -1224,10 +1227,16 @@ MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
switch (flag) {
case GMR_VISIBLE:
{
/*FIXME: currently multicalendar feature isn't implelented, so entirely
/*FIXME: currently multicalendar feature isn't implemented, so entirely
visible month is current */
st[0] = st[1] = infoPtr->curSel;
if (infoPtr->curSel.wMonth == min_allowed_date.wMonth &&
infoPtr->curSel.wYear == min_allowed_date.wYear)
{
st[0].wDay = min_allowed_date.wDay;
}
else
st[0].wDay = 1;
st[0].wDayOfWeek = MONTHCAL_CalculateDayOfWeek(1, st[0].wMonth, st[0].wYear);
......@@ -1239,7 +1248,7 @@ MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
}
case GMR_DAYSTATE:
{
/*FIXME: currently multicalendar feature isn't implelented,
/*FIXME: currently multicalendar feature isn't implemented,
min date from previous month and max date from next one returned */
MONTHCAL_GetMinDate(infoPtr, &st[0]);
MONTHCAL_GetMaxDate(infoPtr, &st[1]);
......@@ -1625,7 +1634,7 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
lpht->st.wDay = day;
}
/* always update day of week */
lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(day, lpht->st.wMonth,
lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(lpht->st.wDay, lpht->st.wMonth,
lpht->st.wYear);
goto done;
}
......
......@@ -1350,6 +1350,7 @@ static void test_monthcal_monthrange(void)
int res;
SYSTEMTIME st_visible[2], st_daystate[2], st;
HWND hwnd;
RECT r;
hwnd = create_monthcal_control(0);
......@@ -1404,6 +1405,30 @@ static void test_monthcal_monthrange(void)
ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_monthrange_seq, "monthcal monthrange", FALSE);
/* resize control to display single Calendar */
res = SendMessage(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r);
MoveWindow(hwnd, 0, 0, r.right, r.bottom, FALSE);
memset(&st, 0, sizeof(st));
st.wMonth = 9;
st.wYear = 1752;
st.wDay = 14;
res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st);
expect(1, res);
/* September 1752 has 19 days */
res = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st_visible);
expect(1, res);
expect(1752, st_visible[0].wYear);
expect(9, st_visible[0].wMonth);
expect(14, st_visible[0].wDay);
expect(1752, st_visible[1].wYear);
expect(9, st_visible[1].wMonth);
expect(19, st_visible[1].wDay);
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