15DateTime::DateTime(uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour, uint8_t day,
Month month, uint16_t year)
50 uint16_t
day = 365,
year = 1970;
84 uint8_t sec = this->
second();
85 uint8_t min = this->
minute();
86 uint8_t hrs = this->
hour();
88 uint8_t mon = this->
month();
93 uint8_t leapYears = 0;
95 for (uint16_t i = 1970; i <
year; i++)
106 ts += ((years * 365) + (leapYears * 366)) *
static_cast<uint64_t
>(86400);
109 for (uint8_t i =
static_cast<uint8_t
>(
January); i < mon; i++)
114 ts += (
day - 1) * 86400;
121 SEMF_INFO(
"unixTimeInSeconds %u out of y %u; m %u; d %u; h %u; m %m; s %u", ts,
year, mon,
day, hrs, min, sec);
131 adddays = hours / 24;
132 hours -= adddays * 24;
133 adddays += (
hour() + hours) / 24;
134 setHour(
static_cast<uint8_t
>((
hour() + hours) % 24));
138 if ((
static_cast<int32_t
>(
hour()) + hours) >= 0)
140 setHour(
static_cast<uint8_t
>(
hour() + hours) % 24);
144 adddays = ((hours +
hour()) / 24) - 1;
145 setHour(
static_cast<uint8_t
>((24 +
hour() + hours) % 24));
154 if (Date::operator==(
static_cast<Date>(other)) && Time::operator==(
static_cast<Time>(other)))
166 return !(*
this == other);
171 if (Date::operator<(
static_cast<Date>(other)) || (Date::operator==(
static_cast<Date>(other)) && Time::operator<(
static_cast<Time>(other))))
183 return (*
this < other || *
this == other);
188 return !(*
this <= other);
193 return !(*
this < other);
The Date class provides date functions.
uint16_t year() const
Returns the year.
static bool isValid(uint8_t day, Month month, uint16_t year)
Returns if the given date is valid.
void addDays(int32_t days)
Adds days to this date.
static bool isLeapYear(uint16_t year)
Returns if a specific year is a leap year or not.
static uint8_t daysInMonth(Month month, uint16_t year)
Returns the number of days in a specific month and year.
uint8_t day() const
Returns the day.
Month month() const
Returns the month.
bool setDate(uint8_t day, Month month, uint16_t year)
Sets date information.
The DateTime class provides date and time functionality as a point of time. It combines features of t...
bool operator==(const DateTime &other) const
Compares this date time with other.
void addHours(int32_t hours)
Adds hours to this datetime.
uint64_t unixTimeInSeconds() const
Returns the date time in seconds since the 1 January 1970.
bool operator<=(const DateTime &other) const
Compares this date time with other.
bool operator>=(const DateTime &other) const
Compares this date time with other.
bool operator>(const DateTime &other) const
Compares this date time with other.
bool operator!=(const DateTime &other) const
Compares this date time with other.
bool operator<(const DateTime &other) const
Compares this date time with other.
bool setDateTime(uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour, uint8_t day, Month month, uint16_t year)
Sets date time information and system clock if Rtc is registered.
The Time class provides clock time functions.
uint16_t millisecond() const
Returns the milliseconds from system clock or static value.
static bool isValid(uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour)
Returns if the given time is valid.
bool setTime(uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour)
Sets date time information and system clock if Rtc is registered.
bool setHour(uint8_t hour)
Sets the hours.
uint8_t second() const
Returns the seconds from system clock or static value.
uint8_t minute() const
Returns the minutes.
uint8_t hour() const
Returns the hours.