Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/STM32RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ void STM32RTC::begin(bool resetTime, Hour_Format format)
, resetTime);
_timeSet = !reinit;

syncTime();
syncDate();
syncTime();

/* fix race condition where date may have changed between reading date and time */
if (_seconds == 0 && _minutes == 0 && _hours == 0) {
syncDate();
}

syncAlarmTime();
if (!IS_RTC_DATE(_alarmDay)) {
// Use current time to init alarm members,
Expand Down Expand Up @@ -1109,6 +1115,11 @@ time_t STM32RTC::getEpoch(uint32_t *subSeconds)
syncDate();
syncTime();

/* fix race condition where date may have changed between reading date and time */
if (_seconds == 0 && _minutes == 0 && _hours == 0) {
syncDate();
}

tm.tm_isdst = -1;
/*
* mktime ignores the values supplied by the caller in the
Expand Down
Loading