File tree Expand file tree Collapse file tree
STM32F4/libraries/RTClock/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,17 +219,17 @@ time_t RTClock::getTime() {
219219 int secs = 10 * ((tr_reg & 0x00000070 ) >> 4 ) + (tr_reg & 0x0000000F );
220220 // seconds from 1970 till 1 jan 00:00:00 of the given year
221221 time_t t = (years + 30 ) * SECS_PER_DAY * 365 ;
222- for (int i = 0 ; i < years; i++) {
222+ for (int i = 0 ; i < ( years + 30 ) ; i++) {
223223 if (LEAP_YEAR (i)) {
224224 t += SECS_PER_DAY; // add extra days for leap years
225225 }
226226 }
227227 // add days for this year, months start from 1
228228 for (int i = 1 ; i < months; i++) {
229229 if ( (i == 2 ) && LEAP_YEAR (years)) {
230- t += SECS_PER_DAY * 29 ;
230+ t += SECS_PER_DAY * 29 ;
231231 } else {
232- t += SECS_PER_DAY * monthDays[i - 1 ]; // monthDays array starts from 0
232+ t += SECS_PER_DAY * monthDays[i - 1 ]; // monthDays array starts from 0
233233 }
234234 }
235235 t += (days - 1 ) * SECS_PER_DAY + hours * SECS_PER_HOUR + mins * SECS_PER_MIN + secs;
You can’t perform that action at this time.
0 commit comments