27 ESP_LOGVV(TAG,
"Got epoch %" PRIu32, epoch);
32 ts.tv_sec =
static_cast<time_t
>(epoch);
34 int ret = clock_settime(CLOCK_REALTIME, &ts);
37 ESP_LOGW(TAG,
"clock_settime() failed with code %d", ret);
40 struct timeval timev {
41 .tv_sec =
static_cast<time_t
>(epoch), .tv_usec = 0,
43 struct timezone tz = {0, 0};
44 int ret = settimeofday(&timev, &tz);
48 ret = settimeofday(&timev,
nullptr);
51#ifdef USE_TIME_TIMEZONE
57 ESP_LOGW(TAG,
"setimeofday() failed with code %d", ret);
60 auto time = this->
now();
61 ESP_LOGD(TAG,
"Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month, time.hour,
62 time.minute, time.second);