Initialize all fields in ESPTime in PCF85063 (#4439)

This commit is contained in:
Oxan van Leeuwen 2023-02-14 23:45:27 +01:00 committed by GitHub
parent 8b5b9e508b
commit 5307dfee21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,14 +37,18 @@ void PCF85063Component::read_time() {
ESP_LOGW(TAG, "RTC halted, not syncing to system clock."); ESP_LOGW(TAG, "RTC halted, not syncing to system clock.");
return; return;
} }
time::ESPTime rtc_time{.second = uint8_t(pcf85063_.reg.second + 10 * pcf85063_.reg.second_10), time::ESPTime rtc_time{
.minute = uint8_t(pcf85063_.reg.minute + 10u * pcf85063_.reg.minute_10), .second = uint8_t(pcf85063_.reg.second + 10 * pcf85063_.reg.second_10),
.hour = uint8_t(pcf85063_.reg.hour + 10u * pcf85063_.reg.hour_10), .minute = uint8_t(pcf85063_.reg.minute + 10u * pcf85063_.reg.minute_10),
.day_of_week = uint8_t(pcf85063_.reg.weekday), .hour = uint8_t(pcf85063_.reg.hour + 10u * pcf85063_.reg.hour_10),
.day_of_month = uint8_t(pcf85063_.reg.day + 10u * pcf85063_.reg.day_10), .day_of_week = uint8_t(pcf85063_.reg.weekday),
.day_of_year = 1, // ignored by recalc_timestamp_utc(false) .day_of_month = uint8_t(pcf85063_.reg.day + 10u * pcf85063_.reg.day_10),
.month = uint8_t(pcf85063_.reg.month + 10u * pcf85063_.reg.month_10), .day_of_year = 1, // ignored by recalc_timestamp_utc(false)
.year = uint16_t(pcf85063_.reg.year + 10u * pcf85063_.reg.year_10 + 2000)}; .month = uint8_t(pcf85063_.reg.month + 10u * pcf85063_.reg.month_10),
.year = uint16_t(pcf85063_.reg.year + 10u * pcf85063_.reg.year_10 + 2000),
.is_dst = false, // not used
.timestamp = 0, // overwritten by recalc_timestamp_utc(false)
};
rtc_time.recalc_timestamp_utc(false); rtc_time.recalc_timestamp_utc(false);
if (!rtc_time.is_valid()) { if (!rtc_time.is_valid()) {
ESP_LOGE(TAG, "Invalid RTC time, not syncing to system clock."); ESP_LOGE(TAG, "Invalid RTC time, not syncing to system clock.");