![]() |
semf
|
The DateTime
class provides date and time functionality as a point of time. It combines features of the Date
and Time
classes (via inheritance).
More...
#include <datetime.h>
Public Member Functions | |
DateTime ()=default | |
DateTime (uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour, uint8_t day, Month month, uint16_t year) | |
Copy Constructor. More... | |
DateTime (uint64_t unixTimeInSeconds) | |
Sets date time information. More... | |
virtual | ~DateTime ()=default |
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. More... | |
bool | setDateTime (const Time ©FromTime, const Date ©FromDate) |
Sets date time information. More... | |
void | setDateTime (uint64_t unixTimeInSeconds) |
Sets date time information. More... | |
uint64_t | unixTimeInSeconds () const |
Returns the date time in seconds since the 1 January 1970. More... | |
void | addHours (int32_t hours) |
Adds hours to this datetime. More... | |
bool | operator== (const DateTime &other) const |
Compares this date time with other . More... | |
bool | operator!= (const DateTime &other) const |
Compares this date time with other . More... | |
bool | operator< (const DateTime &other) const |
Compares this date time with other . More... | |
bool | operator<= (const DateTime &other) const |
Compares this date time with other . More... | |
bool | operator> (const DateTime &other) const |
Compares this date time with other . More... | |
bool | operator>= (const DateTime &other) const |
Compares this date time with other . More... | |
![]() | |
Date ()=default | |
Date (uint8_t day, Month month, uint16_t year) | |
Constructor. More... | |
virtual | ~Date ()=default |
bool | setDate (uint8_t day, Month month, uint16_t year) |
Sets date information. More... | |
uint8_t | day () const |
Returns the day. More... | |
bool | setDay (uint8_t day) |
Sets a day. More... | |
Month | month () const |
Returns the month. More... | |
bool | setMonth (Month month) |
Sets a month. More... | |
uint16_t | year () const |
Returns the year. More... | |
bool | setYear (uint16_t year) |
Sets a year. More... | |
void | addDays (int32_t days) |
Adds days to this date. More... | |
Weekday | weekday () const |
Returns the day in the week of the actual Date . More... | |
void | addMonths (int32_t months) |
Adds months to this date. More... | |
void | addYears (int32_t years) |
Adds years to this date. More... | |
bool | operator== (const Date &dateToCompareWith) const |
Compares this date with other . More... | |
bool | operator!= (const Date &dateToCompareWith) const |
Compares this date with other . More... | |
bool | operator< (const Date &dateToCompareWith) const |
Compares this date with other . More... | |
bool | operator<= (const Date &dateToCompareWith) const |
Compares this date with other . More... | |
bool | operator> (const Date &dateToCompareWith) const |
Compares this date with other . More... | |
bool | operator>= (const Date &dateToCompareWith) const |
Compares this date with other . More... | |
![]() | |
Time ()=default | |
Time (const Time &timeToSet) | |
Copy constructor. More... | |
Time (uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour) | |
Constructor for static time. More... | |
virtual | ~Time ()=default |
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. More... | |
uint16_t | millisecond () const |
Returns the milliseconds from system clock or static value. More... | |
bool | setMillisecond (uint16_t millisecond) |
Sets the milliseconds. More... | |
uint8_t | second () const |
Returns the seconds from system clock or static value. More... | |
bool | setSecond (uint8_t second) |
Sets the seconds. More... | |
uint8_t | minute () const |
Returns the minutes. More... | |
bool | setMinute (uint8_t minute) |
Sets the minutes. More... | |
uint8_t | hour () const |
Returns the hours. More... | |
bool | setHour (uint8_t hour) |
Sets the hours. More... | |
void | addMilliseconds (int32_t milliseconds) |
Adds milliseconds to this time. More... | |
void | addSeconds (int32_t seconds) |
Adds seconds to this time. More... | |
void | addMinutes (int32_t minutes) |
Adds minutes to this time. More... | |
void | addHours (int32_t hours) |
Adds hours to this time. More... | |
uint32_t | secondsSinceStartOfDay () const |
Returns the seconds since start of the day. More... | |
uint32_t | millisecondsSinceStartOfDay () const |
Returns the milliseconds since start of the day. More... | |
int32_t | timeSpan (const Time &subtract) const |
Returns a time difference between this time and subtract . More... | |
Time & | operator= (const Time &timeToSet) |
Copies the time. More... | |
bool | operator== (const Time &timeToCompareWith) const |
Compares this time with other . More... | |
bool | operator!= (const Time &timeToCompareWith) const |
Compares this time with other . More... | |
bool | operator< (const Time &timeToCompareWith) const |
Compares this time with other . More... | |
bool | operator<= (const Time &timeToCompareWith) const |
Compares this time with other . More... | |
bool | operator> (const Time &timeToCompareWith) const |
Compares this time with other . More... | |
bool | operator>= (const Time &timeToCompareWith) const |
Compares this time with other . More... | |
Additional Inherited Members | |
![]() | |
enum | Month { January = 1 , February , March , April , May , June , July , August , September , October , November , December } |
enum | Weekday { Sunday = 0 , Monday , Tuesday , Wednesday , Thursday , Friday , Saturday } |
![]() | |
static uint8_t | daysInMonth (Month month, uint16_t year) |
Returns the number of days in a specific month and year. More... | |
static bool | isLeapYear (uint16_t year) |
Returns if a specific year is a leap year or not. More... | |
static bool | isValid (uint8_t day, Month month, uint16_t year) |
Returns if the given date is valid. More... | |
![]() | |
static bool | isValid (uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour) |
Returns if the given time is valid. More... | |
The DateTime
class provides date and time functionality as a point of time. It combines features of the Date
and Time
classes (via inheritance).
The date and time can be modified by
setDateTime()
,setDate()
andsetTime()
.DateTime
provides a full set of operators to compare two DateTime
objects where smaller means earlier, and larger means later.
Definition at line 30 of file datetime.h.
|
default |
semf::DateTime::DateTime | ( | uint16_t | millisecond, |
uint8_t | second, | ||
uint8_t | minute, | ||
uint8_t | hour, | ||
uint8_t | day, | ||
Month | month, | ||
uint16_t | year | ||
) |
Copy Constructor.
millisecond | Milliseconds to set. |
second | Seconds to set. |
minute | Minutes to set. |
hour | Hours to set. |
day | Day to set. |
month | Month to set. |
year | Year to set. |
Definition at line 15 of file datetime.cpp.
|
explicit |
Sets date time information.
unixTimeInSeconds | Unix time in seconds. |
Definition at line 20 of file datetime.cpp.
|
virtualdefault |
void semf::DateTime::addHours | ( | int32_t | hours | ) |
Adds hours to this
datetime.
hours | Hours to add. |
Definition at line 125 of file datetime.cpp.
bool semf::DateTime::operator!= | ( | const DateTime & | other | ) | const |
Compares this
date time with other
.
other | date time to compare. |
true
if date times are different; false
if date times are the same. Definition at line 164 of file datetime.cpp.
bool semf::DateTime::operator< | ( | const DateTime & | other | ) | const |
Compares this
date time with other
.
other | date time to compare. |
true
if this
date time is smaller; false
if not. Definition at line 169 of file datetime.cpp.
bool semf::DateTime::operator<= | ( | const DateTime & | other | ) | const |
Compares this
date time with other
.
other | date time to compare. |
true
if this
date time is smaller or equal; false
if not. Definition at line 181 of file datetime.cpp.
bool semf::DateTime::operator== | ( | const DateTime & | other | ) | const |
Compares this
date time with other
.
other | date time to compare. |
true
if date times are the same; false
if date times are different. Definition at line 152 of file datetime.cpp.
bool semf::DateTime::operator> | ( | const DateTime & | other | ) | const |
Compares this
date time with other
.
other | date time to compare. |
true
if this
date time is larger; false
if not. Definition at line 186 of file datetime.cpp.
bool semf::DateTime::operator>= | ( | const DateTime & | other | ) | const |
Compares this
date time with other
.
other | date time to compare. |
true
if this
date time is larger or equal; false
if not. Definition at line 191 of file datetime.cpp.
Sets date time information.
true
for DateTime is valid, false
for not. Definition at line 41 of file datetime.cpp.
bool semf::DateTime::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.
millisecond | Milliseconds to set. |
second | Seconds to set. |
minute | Minutes to set. |
hour | Hours to set. |
day | Day to set. |
month | Month to set. |
year | Year to set. |
true
for DateTime is valid, false
for not. Definition at line 25 of file datetime.cpp.
void semf::DateTime::setDateTime | ( | uint64_t | unixTimeInSeconds | ) |
Sets date time information.
unixTimeInSeconds | Unix time in seconds. |
Definition at line 47 of file datetime.cpp.
uint64_t semf::DateTime::unixTimeInSeconds | ( | ) | const |
Returns the date time in seconds since the 1 January 1970.
Definition at line 82 of file datetime.cpp.