43 size_t strftime(
char *buffer,
size_t buffer_len,
const char *format);
51 std::string
strftime(
const std::string &format);
58 return this->second < 61 && this->minute < 60 && this->hour < 24 && this->day_of_week > 0 &&
59 this->day_of_week < 8 && this->day_of_month > 0 && this->day_of_month < 32 && this->day_of_year > 0 &&
60 this->day_of_year < 367 && this->month > 0 && this->month < 13;
72 struct tm *c_tm = ::localtime(&epoch);
81 struct tm *c_tm = ::gmtime(&epoch);
129 void call_setup()
override;
132 this->time_sync_callback_.add(std::move(callback));
137 void synchronize_epoch_(uint32_t epoch);
139 std::string timezone_{};
140 void apply_timezone_();
148 bool check(Ts... x)
override {
return this->parent_->now().is_valid(); }
uint8_t month
month; january=1 [1-12]
ESPTime now()
Get the time in the currently defined timezone.
TimeHasTimeCondition(RealTimeClock *parent)
bool check(Ts... x) override
bool is_valid() const
Check if this ESPTime is valid (all fields in range and year is greater than 2018) ...
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock...
time_t timestamp
unix epoch time (seconds since UTC Midnight January 1, 1970)
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.
std::string get_timezone()
Get the time zone currently in use.
void add_on_time_sync_callback(std::function< void()> callback)
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...
This class simplifies creating components that periodically check a state.
void increment_second()
Increment this clock instance by one second.
void set_timezone(const std::string &tz)
Set the time zone.
static ESPTime from_epoch_local(time_t epoch)
Convert an UTC epoch timestamp to a local time ESPTime instance.
CallbackManager< void()> time_sync_callback_
bool is_dst
daylight saving time flag
uint8_t minute
minutes after the hour [0-59]
void increment_day()
Increment this clock instance by one day.
uint16_t day_of_year
day of the year [1-366]
A more user-friendly version of struct tm from time.h.
Base class for all automation conditions.
time_t timestamp_now()
Get the current time as the UTC epoch since January 1st 1970.
bool operator<=(ESPTime other)
static ESPTime from_epoch_utc(time_t epoch)
Convert an UTC epoch timestamp to a UTC time ESPTime instance.
uint8_t second
seconds after the minute [0-60]
bool operator==(ESPTime other)
bool fields_in_range() const
Check if all time fields of this ESPTime are in range.
bool operator>(ESPTime other)
bool operator<(ESPTime other)
ESPTime utcnow()
Get the time without any time zone or DST corrections.
uint8_t day_of_week
day of the week; sunday=1 [1-7]
uint8_t day_of_month
day of the month [1-31]
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)...
static int32_t timezone_offset()
uint8_t hour
hours since midnight [0-23]
bool operator>=(ESPTime other)