A simple value type representing a time of day (hour, minute, second).
More...
#include <TimeOfDay.h>
Definition at line 21 of file TimeOfDay.h.
◆ fromString()
static TimeOfDay TimeOfDay::fromString |
( |
const char * |
hhmm | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- Parsed TimeOfDay (defaults to 00:00:00 on error).
Definition at line 32 of file TimeOfDay.h.
32 {
35 return t;
36 }
else if (sscanf(hhmm,
"%2hhu:%2hhu", &t.
hour, &t.
minute) == 2) {
38 return t;
39 }
40 return {0, 0, 0};
41 }
A simple value type representing a time of day (hour, minute, second).
References hour, minute, and second.
Referenced by from_json().
◆ operator!=()
bool TimeOfDay::operator!= |
( |
const TimeOfDay & |
other | ) |
const |
|
inline |
Definition at line 64 of file TimeOfDay.h.
64 {
65 return !(*this == other);
66 }
◆ operator<()
bool TimeOfDay::operator< |
( |
const TimeOfDay & |
other | ) |
const |
|
inline |
◆ operator<=()
bool TimeOfDay::operator<= |
( |
const TimeOfDay & |
other | ) |
const |
|
inline |
Definition at line 74 of file TimeOfDay.h.
74 {
75 return !(*this > other);
76 }
◆ operator==()
bool TimeOfDay::operator== |
( |
const TimeOfDay & |
other | ) |
const |
|
inline |
◆ operator>()
bool TimeOfDay::operator> |
( |
const TimeOfDay & |
other | ) |
const |
|
inline |
Definition at line 78 of file TimeOfDay.h.
78 {
79 return other < *this;
80 }
◆ operator>=()
bool TimeOfDay::operator>= |
( |
const TimeOfDay & |
other | ) |
const |
|
inline |
Definition at line 82 of file TimeOfDay.h.
82 {
83 return !(*this < other);
84 }
◆ toString()
static std::string TimeOfDay::toString |
( |
const TimeOfDay & |
time | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- Formatted string, either "HH:MM" or "HH:MM:SS" depending on seconds.
Definition at line 48 of file TimeOfDay.h.
48 {
49 char buf[9];
51 snprintf(buf,
sizeof(buf),
"%02u:%02u:%02u", time.
hour, time.
minute, time.
second);
52 } else {
53 snprintf(buf,
sizeof(buf),
"%02u:%02u", time.
hour, time.
minute);
54 }
55 return std::string(buf);
56 }
References hour, minute, and second.
Referenced by to_json().
◆ hour
uint8_t TimeOfDay::hour = 0 |
◆ minute
uint8_t TimeOfDay::minute = 0 |
◆ second
uint8_t TimeOfDay::second = 0 |
The documentation for this struct was generated from the following file: