Fix time component for host platform (#6118)

This commit is contained in:
Clyde Stubbs 2024-01-19 12:46:55 +11:00 committed by GitHub
parent 8267b3274c
commit 2283b3b443
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,10 @@
#include "real_time_clock.h"
#include "esphome/core/log.h"
#ifdef USE_HOST
#include <sys/time.h>
#else
#include "lwip/opt.h"
#endif
#ifdef USE_ESP8266
#include "sys/time.h"
#endif
@ -25,7 +29,7 @@ void RealTimeClock::synchronize_epoch_(uint32_t epoch) {
.tv_sec = static_cast<time_t>(epoch), .tv_usec = 0,
};
ESP_LOGVV(TAG, "Got epoch %" PRIu32, epoch);
timezone tz = {0, 0};
struct timezone tz = {0, 0};
int ret = settimeofday(&timev, &tz);
if (ret == EINVAL) {
// Some ESP8266 frameworks abort when timezone parameter is not NULL