diff --git a/esphome/components/time/real_time_clock.cpp b/esphome/components/time/real_time_clock.cpp index 2b9a95c6bd..11e39e8f67 100644 --- a/esphome/components/time/real_time_clock.cpp +++ b/esphome/components/time/real_time_clock.cpp @@ -21,10 +21,6 @@ namespace time { static const char *const TAG = "time"; RealTimeClock::RealTimeClock() = default; -void RealTimeClock::call_setup() { - this->apply_timezone_(); - PollingComponent::call_setup(); -} void RealTimeClock::synchronize_epoch_(uint32_t epoch) { // Update UTC epoch time. struct timeval timev { diff --git a/esphome/components/time/real_time_clock.h b/esphome/components/time/real_time_clock.h index a17168ae6f..401798a568 100644 --- a/esphome/components/time/real_time_clock.h +++ b/esphome/components/time/real_time_clock.h @@ -21,7 +21,10 @@ class RealTimeClock : public PollingComponent { explicit RealTimeClock(); /// Set the time zone. - void set_timezone(const std::string &tz) { this->timezone_ = tz; } + void set_timezone(const std::string &tz) { + this->timezone_ = tz; + this->apply_timezone_(); + } /// Get the time zone currently in use. std::string get_timezone() { return this->timezone_; } @@ -35,8 +38,6 @@ class RealTimeClock : public PollingComponent { /// Get the current time as the UTC epoch since January 1st 1970. time_t timestamp_now() { return ::time(nullptr); } - void call_setup() override; - void add_on_time_sync_callback(std::function callback) { this->time_sync_callback_.add(std::move(callback)); };