40 auto val = [](
int off,
int y) {
return off +
y * 365 +
y / 4 -
y / 100 +
y / 400; };
41 return nYear < 0 ? val(-366, nYear + 1) : val(0, nYear - 1);
59 return (((nYear % 4) == 0) && ((nYear % 100) != 0)) || ((nYear % 400) == 0);
67constexpr inline sal_uInt16
getDaysInMonth(sal_uInt16 nMonth, sal_Int16 nYear)
69 assert(1 <= nMonth && nMonth <= 12);
70 if (nMonth < 1 || 12 < nMonth)
73 constexpr sal_uInt16 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
74 sal_uInt16
n = aDaysInMonth[nMonth - 1];
82constexpr inline sal_Int32
convertDateToDays(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
85 for (sal_uInt16
i = 1;
i < nMonth; ++
i)
#define COMPHELPER_DLLPUBLIC
constexpr sal_uInt16 getDaysInMonth(sal_uInt16 nMonth, sal_Int16 nYear)
Get number of days in month of year.
constexpr bool isLeapYear(sal_Int16 nYear)
Whether year is a leap year.
void convertDaysToDate(sal_Int32 nDays, sal_uInt16 &rDay, sal_uInt16 &rMonth, sal_Int16 &rYear)
Obtain date for a days from zero value.
bool isValidDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
Whether date is a valid date.
constexpr sal_Int32 YearToDays(sal_Int16 nYear)
Days until start of year from zero, so month and day of month can be added.
constexpr sal_Int32 convertDateToDays(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
Obtain days from zero for a given date, without normalizing.
bool normalize(sal_uInt16 &rDay, sal_uInt16 &rMonth, sal_Int16 &rYear)
Normalize date, i.e.
sal_Int32 convertDateToDaysNormalizing(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
Obtain days from zero for a given date, with normalizing.