[PATCH 3/3] Always store a recalculated day of week instead of a value passed in (DTM_SETSYSTEMTIME)

Nikolay Sivov bunglehead at gmail.com
Wed Sep 30 18:11:00 CDT 2009


---
 dlls/comctl32/comctl32.h       |    1 +
 dlls/comctl32/datetime.c       |   11 ++++++++---
 dlls/comctl32/monthcal.c       |    2 +-
 dlls/comctl32/tests/datetime.c |    6 +++---
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h
index fd07110..e0d1970 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 224519a..8f7f5dd 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 fcfc7eb..71e477e 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 26d7ea1..c449e45 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);
 }
-- 
1.5.6.5


--=-TcGLHbJ4u0wtwCuw2px8--




More information about the wine-patches mailing list