From a00c217ce910bc20f5c40a0a864c588dc720bf37 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 10 Oct 2009 21:20:26 +0400 Subject: [PATCH] comctl32/monthcal: Reuse existing calls to get day of week. --- dlls/comctl32/monthcal.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index fc735372df3..d75526a1923 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -131,10 +131,6 @@ typedef struct WNDPROC EditWndProc; /* original Edit window procedure */ } MONTHCAL_INFO, *LPMONTHCAL_INFO; - -/* Offsets of days in the week to the weekday of january 1 in a leap year */ -static const int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; - static const WCHAR themeClass[] = { 'S','c','r','o','l','l','b','a','r',0 }; /* empty SYSTEMTIME const */ @@ -389,10 +385,18 @@ static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to) */ int MONTHCAL_CalculateDayOfWeek(WORD day, WORD month, WORD year) { - year-=(month < 3); + FILETIME ft; + SYSTEMTIME st; - return((year + year/4 - year/100 + year/400 + - DayOfWeekTable[month-1] + day ) % 7); + st.wYear = year; + st.wMonth = month; + st.wDay = day; + st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0; + + SystemTimeToFileTime(&st, &ft); + FileTimeToSystemTime(&ft, &st); + + return st.wDayOfWeek; } /* properly updates date to point on next month */