99 int32_t addmonths = 0;
106 while (days +
day() > daysinmonth)
120 while (days +
day() < 1)
133 m_day =
static_cast<uint8_t
>(m_day + days);
140 int32_t addyears = 0;
144 addyears = months / 12;
145 months -= addyears * 12;
146 addyears += (
month() + months - 1) / 12;
147 m_month =
static_cast<Month>(((
month() + months - 1) % 12) + 1);
151 if (months +
static_cast<uint8_t
>(
month()) < 1)
153 addyears = ((months +
static_cast<uint8_t
>(
month()) - 1) / 12) - 1;
154 months -= addyears * 12;
156 m_month =
static_cast<Month>(months +
static_cast<uint8_t
>(
month()));
164 if (
static_cast<int32_t
>(
year()) + years >= 0)
166 m_year =
static_cast<uint16_t
>(m_year + years);
179 static const uint8_t t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
181 y -=
static_cast<uint8_t
>(m_month) < 3;
182 return static_cast<Weekday>((y + y / 4 - y / 100 + y / 400 + t[
static_cast<uint8_t
>(m_month) - 1] + m_day) % 7);
199 return !(*
this == dateToCompareWith);
217 return (*
this < dateToCompareWith || *
this == dateToCompareWith);
222 return !(*
this <= dateToCompareWith);
227 return !(*
this < dateToCompareWith);
262 return (((
year) % 4 == 0) && ((
year) % 100 != 0)) || ((
year) % 400 == 0);
268 return (daysinmonth > 0 &&
day != 0 &&
day <= daysinmonth) ? true :
false;
The Date class provides date functions.
bool operator>=(const Date &dateToCompareWith) const
Compares this date with other.
uint16_t year() const
Returns the year.
bool operator<(const Date &dateToCompareWith) const
Compares this date with other.
bool operator==(const Date &dateToCompareWith) const
Compares this date with other.
static bool isValid(uint8_t day, Month month, uint16_t year)
Returns if the given date is valid.
void addYears(int32_t years)
Adds years to this date.
void addDays(int32_t days)
Adds days to this date.
Weekday weekday() const
Returns the day in the week of the actual Date.
bool setMonth(Month month)
Sets a month.
static bool isLeapYear(uint16_t year)
Returns if a specific year is a leap year or not.
bool operator>(const Date &dateToCompareWith) const
Compares this date with other.
static uint8_t daysInMonth(Month month, uint16_t year)
Returns the number of days in a specific month and year.
bool setDay(uint8_t day)
Sets a day.
uint8_t day() const
Returns the day.
bool setYear(uint16_t year)
Sets a year.
Month month() const
Returns the month.
bool operator<=(const Date &dateToCompareWith) const
Compares this date with other.
bool operator!=(const Date &dateToCompareWith) const
Compares this date with other.
void addMonths(int32_t months)
Adds months to this date.
bool setDate(uint8_t day, Month month, uint16_t year)
Sets date information.