4#ifdef USE_DATETIME_DATE
10static const char *
const TAG =
"datetime.date_entity";
19 ESP_LOGE(TAG,
"Year must be between 1970 and 3000");
24 ESP_LOGE(TAG,
"Month must be between 1 and 12");
35#if defined(USE_DATETIME_DATE) && defined(USE_CONTROLLER_REGISTRY)
36 ControllerRegistry::notify_date_update(
this);
41 if (this->
year_.has_value() && (this->year_ < 1970 || this->year_ > 3000)) {
42 ESP_LOGE(TAG,
"Year must be between 1970 and 3000");
47 if (this->
month_.has_value() && (this->month_ < 1 || this->month_ > 12)) {
48 ESP_LOGE(TAG,
"Month must be between 1 and 12");
52 if (this->
day_.has_value()) {
55 if (this->
month_.has_value()) {
61 ESP_LOGE(TAG,
"Month must be set to validate day");
65 if (this->
year_.has_value()) {
71 ESP_LOGE(TAG,
"Year must be set to validate day");
86 if (this->
year_.has_value()) {
87 ESP_LOGV(TAG,
" Year: %d", *this->
year_);
89 if (this->
month_.has_value()) {
90 ESP_LOGV(TAG,
" Month: %d", *this->
month_);
92 if (this->
day_.has_value()) {
93 ESP_LOGV(TAG,
" Day: %d", *this->
day_);
110 ESP_LOGE(TAG,
"Could not convert the date string to an ESPTime object");
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< uint16_t > year_
optional< uint8_t > month_
virtual void control(const DateCall &call)=0
LazyCallbackManager< void()> state_callback_
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 char *time_to_parse, size_t len, 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)