comctl32/monthcal: Add helper to jump to specified number of months.

This commit is contained in:
Nikolay Sivov 2010-08-01 10:25:00 +04:00 committed by Alexandre Julliard
parent 23e9866be8
commit b83d11ace4

View File

@ -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 */