Module: wine Branch: master Commit: b83d11ace4d5dbdef07a8e777529b8b12f2734a1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b83d11ace4d5dbdef07a8e7775...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Sun Aug 1 10:25:00 2010 +0400
comctl32/monthcal: Add helper to jump to specified number of months.
---
dlls/comctl32/monthcal.c | 30 ++++++++++++------------------ 1 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 5f5c7c2..91cd4cb 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -455,36 +455,30 @@ int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace) return st.wDayOfWeek; }
-/* properly updates date to point on next month */ -static inline void MONTHCAL_GetNextMonth(SYSTEMTIME *date) +/* add/substract 'months' from date */ +static inline void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months) { INT length;
- if(++date->wMonth > 12) - { - date->wMonth = 1; - date->wYear++; - } + date->wMonth += months; + date->wYear += date->wMonth > 0 ? (date->wMonth - 1) / 12 : date->wMonth / 12 - 1; + date->wMonth = date->wMonth > 0 ? (date->wMonth - 1) % 12 + 1 : 12 + date->wMonth % 12; /* fix moving from last day in a month */ length = MONTHCAL_MonthLength(date->wMonth, date->wYear); if(date->wDay > length) date->wDay = length; MONTHCAL_CalculateDayOfWeek(date, TRUE); }
+/* properly updates date to point on next month */ +static inline void MONTHCAL_GetNextMonth(SYSTEMTIME *date) +{ + return MONTHCAL_GetMonth(date, 1); +} + /* properly updates date to point on prev month */ static inline void MONTHCAL_GetPrevMonth(SYSTEMTIME *date) { - INT length; - - if(--date->wMonth < 1) - { - date->wMonth = 12; - date->wYear--; - } - /* fix moving from last day in a month */ - length = MONTHCAL_MonthLength(date->wMonth, date->wYear); - if(date->wDay > length) date->wDay = length; - MONTHCAL_CalculateDayOfWeek(date, TRUE); + return MONTHCAL_GetMonth(date, -1); }
/* Returns full date for a first currently visible day */