File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,14 @@ void STM32RTC::begin(bool resetTime, Hour_Format format)
69
69
, resetTime);
70
70
_timeSet = !reinit;
71
71
72
- syncTime ();
73
72
syncDate ();
73
+ syncTime ();
74
+
75
+ /* fix race condition where date may have changed between reading date and time */
76
+ if (_seconds == 0 && _minutes == 0 && _hours == 0 ) {
77
+ syncDate ();
78
+ }
79
+
74
80
syncAlarmTime ();
75
81
if (!IS_RTC_DATE (_alarmDay)) {
76
82
// Use current time to init alarm members,
@@ -1109,6 +1115,11 @@ time_t STM32RTC::getEpoch(uint32_t *subSeconds)
1109
1115
syncDate ();
1110
1116
syncTime ();
1111
1117
1118
+ /* fix race condition where date may have changed between reading date and time */
1119
+ if (_seconds == 0 && _minutes == 0 && _hours == 0 ) {
1120
+ syncDate ();
1121
+ }
1122
+
1112
1123
tm .tm_isdst = -1 ;
1113
1124
/*
1114
1125
* mktime ignores the values supplied by the caller in the
You can’t perform that action at this time.
0 commit comments