ESPHome
2024.12.2
|
A more user-friendly version of struct tm from time.h. More...
#include <time.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... | |
void | recalc_timestamp_local () |
Recalculate the timestamp field from the other fields of this ESPTime instance assuming local fields. 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 bool | strptime (const std::string &time_to_parse, ESPTime &esp_time) |
Convert a string to ESPTime struct as specified by the format argument. More... | |
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... | |
|
inline |
|
static |
|
inlinestatic |
|
inlinestatic |
void esphome::ESPTime::increment_day | ( | ) |
void esphome::ESPTime::increment_second | ( | ) |
|
inline |
void esphome::ESPTime::recalc_timestamp_local | ( | ) |
void esphome::ESPTime::recalc_timestamp_utc | ( | bool | use_day_of_year = true | ) |
size_t esphome::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.
std::string esphome::ESPTime::strftime | ( | const std::string & | format | ) |
Convert this ESPTime struct to a string as specified by the format argument.
|
static |
struct tm esphome::ESPTime::to_c_tm | ( | ) |
uint8_t esphome::ESPTime::day_of_month |
uint8_t esphome::ESPTime::day_of_week |
uint16_t esphome::ESPTime::day_of_year |
uint8_t esphome::ESPTime::minute |
uint8_t esphome::ESPTime::second |
time_t esphome::ESPTime::timestamp |