4#ifdef USE_DATETIME_DATE
11static const char *
const TAG =
"datetime.date_entity";
20 ESP_LOGE(TAG,
"Year must be between 1970 and 3000");
25 ESP_LOGE(TAG,
"Month must be between 1 and 12");
36#if defined(USE_DATETIME_DATE) && defined(USE_CONTROLLER_REGISTRY)
44 if (this->
year_.
has_value() && (this->year_ < 1970 || this->year_ > 3000)) {
45 ESP_LOGE(TAG,
"Year must be between 1970 and 3000");
50 if (this->
month_.
has_value() && (this->month_ < 1 || this->month_ > 12)) {
51 ESP_LOGE(TAG,
"Month must be between 1 and 12");
64 ESP_LOGE(TAG,
"Month must be set to validate day");
74 ESP_LOGE(TAG,
"Year must be set to validate day");
90 ESP_LOGD(TAG,
" Year: %d", *this->
year_);
93 ESP_LOGD(TAG,
" Month: %d", *this->
month_);
96 ESP_LOGD(TAG,
" Day: %d", *this->
day_);
113 ESP_LOGE(TAG,
"Could not convert the date string to an ESPTime object");
static void notify_date_update(datetime::DateEntity *obj)
const StringRef & get_name() const
void set_has_state(bool state)
constexpr const char * c_str() const
DateCall & set_date(uint16_t year, uint8_t month, uint8_t day)
optional< uint8_t > month_
optional< int16_t > year_
virtual void control(const DateCall &call)=0
CallbackManager< void()> state_callback_
Providing packet encoding functions for exchanging data with a remote host.
uint8_t days_in_month(uint8_t month, uint16_t year)
A more user-friendly version of struct tm from time.h.
static bool strptime(const std::string &time_to_parse, ESPTime &esp_time)
Convert a string to ESPTime struct as specified by the format argument.
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]
DateCall to_call(DateEntity *date)
void apply(DateEntity *date)