[PATCH 09/21] Handle September 1752 with a special case - it's a 19 day month

Nikolay Sivov bunglehead at gmail.com
Sat Oct 10 14:12:43 CDT 2009


---
 dlls/comctl32/monthcal.c       |   17 +++++++++++++----
 dlls/comctl32/tests/monthcal.c |   25 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index d75526a..9f242ed 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -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,11 +1227,17 @@ 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;
 
-        st[0].wDay = 1;
+        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);
 
         st[1].wDay = MONTHCAL_MonthLength(st[1].wMonth, st[1].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;
   }
diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c
index d767066..3ead3ed 100644
--- a/dlls/comctl32/tests/monthcal.c
+++ b/dlls/comctl32/tests/monthcal.c
@@ -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);
 }
 
-- 
1.5.6.5


--=-pXMKKDqRiNzhzIyYCI07--




More information about the wine-patches mailing list