[PATCH 3/7] Add helper to jump to specified number of months
Nikolay Sivov
nsivov at codeweavers.com
Sun Aug 1 01:25:00 CDT 2010
---
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 */
--
1.5.6.5
--------------020900010308010708040102--
More information about the wine-patches
mailing list