mirror of
https://github.com/reactos/wine.git
synced 2025-02-26 15:57:20 +00:00
comctl32/monthcal: Add helper to jump to specified number of months.
This commit is contained in:
parent
23e9866be8
commit
b83d11ace4
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user