3 #ifdef USE_DATETIME_DATE 10 static const char *
const TAG =
"datetime.date_entity";
17 if (this->year_ < 1970 || this->
year_ > 3000) {
19 ESP_LOGE(TAG,
"Year must be between 1970 and 3000");
22 if (this->month_ < 1 || this->
month_ > 12) {
24 ESP_LOGE(TAG,
"Month must be between 1 and 12");
40 if (this->
year_.has_value() && (this->
year_ < 1970 || this->
year_ > 3000)) {
41 ESP_LOGE(TAG,
"Year must be between 1970 and 3000");
45 ESP_LOGE(TAG,
"Month must be between 1 and 12");
48 if (this->
day_.has_value()) {
51 if (this->
month_.has_value()) {
54 if (this->parent_->month != 0) {
55 month = this->parent_->month;
57 ESP_LOGE(TAG,
"Month must be set to validate day");
61 if (this->
year_.has_value()) {
64 if (this->parent_->year != 0) {
65 year = this->parent_->year;
67 ESP_LOGE(TAG,
"Year must be set to validate day");
72 ESP_LOGE(TAG,
"Day must be between 1 and %d for month %d",
days_in_month(month, year), month);
80 this->parent_->control(*
this);
95 ESP_LOGE(TAG,
"Could not convert the date string to an ESPTime object");
98 return this->set_date(
val);
117 #endif // USE_DATETIME_DATE
A more user-friendly version of struct tm from time.h.
CallbackManager< void()> state_callback_
uint8_t days_in_month(uint8_t month, uint16_t year)
DateCall & set_date(uint16_t year, uint8_t month, uint8_t day)
DateCall to_call(DateEntity *date)
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
uint8_t month
month; january=1 [1-12]
void apply(DateEntity *date)
uint8_t day_of_month
day of the month [1-31]
const StringRef & get_name() const
static bool strptime(const std::string &time_to_parse, ESPTime &esp_time)
Convert a string to ESPTime struct as specified by the format argument.