ESPHome
2023.5.5
|
A more user-friendly version of struct tm from time.h. More...
#include <real_time_clock.h>
Public Member Functions | |
size_t | strftime (char *buffer, size_t buffer_len, const char *format) |
Convert this ESPTime struct to a null-terminated c string buffer as specified by the format argument. More... | |
std::string | strftime (const std::string &format) |
Convert this ESPTime struct to a string as specified by the format argument. More... | |
bool | is_valid () const |
Check if this ESPTime is valid (all fields in range and year is greater than 2018) More... | |
bool | fields_in_range () const |
Check if all time fields of this ESPTime are in range. More... | |
void | recalc_timestamp_utc (bool use_day_of_year=true) |
Recalculate the timestamp field from the other fields of this ESPTime instance (must be UTC). More... | |
struct tm | to_c_tm () |
Convert this ESPTime instance back to a tm struct. More... | |
void | increment_second () |
Increment this clock instance by one second. More... | |
void | increment_day () |
Increment this clock instance by one day. More... | |
bool | operator< (ESPTime other) |
bool | operator<= (ESPTime other) |
bool | operator== (ESPTime other) |
bool | operator>= (ESPTime other) |
bool | operator> (ESPTime other) |
Static Public Member Functions | |
static ESPTime | from_c_tm (struct tm *c_tm, time_t c_time) |
Convert a C tm struct instance with a C unix epoch timestamp to an ESPTime instance. More... | |
static ESPTime | from_epoch_local (time_t epoch) |
Convert an UTC epoch timestamp to a local time ESPTime instance. More... | |
static ESPTime | from_epoch_utc (time_t epoch) |
Convert an UTC epoch timestamp to a UTC time ESPTime instance. More... | |
static int32_t | timezone_offset () |
Data Fields | |
uint8_t | second |
seconds after the minute [0-60] More... | |
uint8_t | minute |
minutes after the hour [0-59] More... | |
uint8_t | hour |
hours since midnight [0-23] More... | |
uint8_t | day_of_week |
day of the week; sunday=1 [1-7] More... | |
uint8_t | day_of_month |
day of the month [1-31] More... | |
uint16_t | day_of_year |
day of the year [1-366] More... | |
uint8_t | month |
month; january=1 [1-12] More... | |
uint16_t | year |
year More... | |
bool | is_dst |
daylight saving time flag More... | |
time_t | timestamp |
unix epoch time (seconds since UTC Midnight January 1, 1970) More... | |
A more user-friendly version of struct tm from time.h.
Definition at line 14 of file real_time_clock.h.
|
inline |
Check if all time fields of this ESPTime are in range.
Definition at line 57 of file real_time_clock.h.
|
static |
Convert a C tm struct instance with a C unix epoch timestamp to an ESPTime instance.
Definition at line 59 of file real_time_clock.cpp.
|
inlinestatic |
Convert an UTC epoch timestamp to a local time ESPTime instance.
epoch | Seconds since 1st January 1970. In UTC. |
Definition at line 71 of file real_time_clock.h.
|
inlinestatic |
Convert an UTC epoch timestamp to a UTC time ESPTime instance.
epoch | Seconds since 1st January 1970. In UTC. |
Definition at line 80 of file real_time_clock.h.
void esphome::time::ESPTime::increment_day | ( | ) |
Increment this clock instance by one day.
Definition at line 145 of file real_time_clock.cpp.
void esphome::time::ESPTime::increment_second | ( | ) |
Increment this clock instance by one second.
Definition at line 118 of file real_time_clock.cpp.
|
inline |
Check if this ESPTime is valid (all fields in range and year is greater than 2018)
Definition at line 54 of file real_time_clock.h.
bool esphome::time::ESPTime::operator< | ( | ESPTime | other | ) |
Definition at line 215 of file real_time_clock.cpp.
bool esphome::time::ESPTime::operator<= | ( | ESPTime | other | ) |
Definition at line 216 of file real_time_clock.cpp.
bool esphome::time::ESPTime::operator== | ( | ESPTime | other | ) |
Definition at line 217 of file real_time_clock.cpp.
bool esphome::time::ESPTime::operator> | ( | ESPTime | other | ) |
Definition at line 219 of file real_time_clock.cpp.
bool esphome::time::ESPTime::operator>= | ( | ESPTime | other | ) |
Definition at line 218 of file real_time_clock.cpp.
void esphome::time::ESPTime::recalc_timestamp_utc | ( | bool | use_day_of_year = true | ) |
Recalculate the timestamp field from the other fields of this ESPTime instance (must be UTC).
Definition at line 162 of file real_time_clock.cpp.
size_t esphome::time::ESPTime::strftime | ( | char * | buffer, |
size_t | buffer_len, | ||
const char * | format | ||
) |
Convert this ESPTime struct to a null-terminated c string buffer as specified by the format argument.
Up to buffer_len bytes are written.
Definition at line 55 of file real_time_clock.cpp.
std::string esphome::time::ESPTime::strftime | ( | const std::string & | format | ) |
Convert this ESPTime struct to a string as specified by the format argument.
Definition at line 86 of file real_time_clock.cpp.
|
static |
Definition at line 191 of file real_time_clock.cpp.
struct tm esphome::time::ESPTime::to_c_tm | ( | ) |
Convert this ESPTime instance back to a tm struct.
Definition at line 73 of file real_time_clock.cpp.
uint8_t esphome::time::ESPTime::day_of_month |
day of the month [1-31]
Definition at line 26 of file real_time_clock.h.
uint8_t esphome::time::ESPTime::day_of_week |
day of the week; sunday=1 [1-7]
Definition at line 24 of file real_time_clock.h.
uint16_t esphome::time::ESPTime::day_of_year |
day of the year [1-366]
Definition at line 28 of file real_time_clock.h.
uint8_t esphome::time::ESPTime::hour |
hours since midnight [0-23]
Definition at line 22 of file real_time_clock.h.
bool esphome::time::ESPTime::is_dst |
daylight saving time flag
Definition at line 34 of file real_time_clock.h.
uint8_t esphome::time::ESPTime::minute |
minutes after the hour [0-59]
Definition at line 20 of file real_time_clock.h.
uint8_t esphome::time::ESPTime::month |
month; january=1 [1-12]
Definition at line 30 of file real_time_clock.h.
uint8_t esphome::time::ESPTime::second |
seconds after the minute [0-60]
Definition at line 18 of file real_time_clock.h.
time_t esphome::time::ESPTime::timestamp |
unix epoch time (seconds since UTC Midnight January 1, 1970)
Definition at line 36 of file real_time_clock.h.
uint16_t esphome::time::ESPTime::year |
year
Definition at line 32 of file real_time_clock.h.