semf
datetime.h
Go to the documentation of this file.
1
10#ifndef SEMF_UTILS_SYSTEM_DATETIME_H_
11#define SEMF_UTILS_SYSTEM_DATETIME_H_
12
15
16namespace semf
17{
30class DateTime : public Date, public Time
31{
32public:
33 DateTime() = default;
44 DateTime(uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour, uint8_t day, Month month, uint16_t year);
49 explicit DateTime(uint64_t unixTimeInSeconds);
50 virtual ~DateTime() = default;
51
64 bool setDateTime(uint16_t millisecond, uint8_t second, uint8_t minute, uint8_t hour, uint8_t day, Month month, uint16_t year);
71 bool setDateTime(const Time& copyFromTime, const Date& copyFromDate);
76 void setDateTime(uint64_t unixTimeInSeconds);
81 uint64_t unixTimeInSeconds() const;
86 void addHours(int32_t hours);
92 bool operator==(const DateTime& other) const;
98 bool operator!=(const DateTime& other) const;
104 bool operator<(const DateTime& other) const;
110 bool operator<=(const DateTime& other) const;
116 bool operator>(const DateTime& other) const;
122 bool operator>=(const DateTime& other) const;
123};
124} /* namespace semf */
125#endif /* SEMF_UTILS_SYSTEM_DATETIME_H_ */
The Date class provides date functions.
Definition: date.h:34
uint16_t year() const
Returns the year.
Definition: date.cpp:77
uint8_t day() const
Returns the day.
Definition: date.cpp:37
Month month() const
Returns the month.
Definition: date.cpp:57
The DateTime class provides date and time functionality as a point of time. It combines features of t...
Definition: datetime.h:31
bool operator==(const DateTime &other) const
Compares this date time with other.
Definition: datetime.cpp:152
DateTime()=default
virtual ~DateTime()=default
void addHours(int32_t hours)
Adds hours to this datetime.
Definition: datetime.cpp:125
uint64_t unixTimeInSeconds() const
Returns the date time in seconds since the 1 January 1970.
Definition: datetime.cpp:82
bool operator<=(const DateTime &other) const
Compares this date time with other.
Definition: datetime.cpp:181
bool operator>=(const DateTime &other) const
Compares this date time with other.
Definition: datetime.cpp:191
bool operator>(const DateTime &other) const
Compares this date time with other.
Definition: datetime.cpp:186
bool operator!=(const DateTime &other) const
Compares this date time with other.
Definition: datetime.cpp:164
bool operator<(const DateTime &other) const
Compares this date time with other.
Definition: datetime.cpp:169
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.
Definition: datetime.cpp:25
The Time class provides clock time functions.
Definition: time.h:37
uint16_t millisecond() const
Returns the milliseconds from system clock or static value.
Definition: time.cpp:43
uint8_t second() const
Returns the seconds from system clock or static value.
Definition: time.cpp:63
uint8_t minute() const
Returns the minutes.
Definition: time.cpp:83
uint8_t hour() const
Returns the hours.
Definition: time.cpp:103