File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -851,8 +851,12 @@ uint32_t STM32RTC::getEpoch(void)
851851 syncTime ();
852852
853853 tm.tm_isdst = -1 ;
854+ /*
855+ * mktime ignores the values supplied by the caller in the
856+ * tm_wday and tm_yday fields
857+ */
854858 tm.tm_yday = 0 ;
855- tm.tm_wday = _wday - 1 ;
859+ tm.tm_wday = 0 ;
856860 tm.tm_year = _year + EPOCH_TIME_YEAR_OFF;
857861 tm.tm_mon = _month - 1 ;
858862 tm.tm_mday = _day;
@@ -911,7 +915,11 @@ void STM32RTC::setEpoch(uint32_t ts)
911915 _year = tmp->tm_year - EPOCH_TIME_YEAR_OFF;
912916 _month = tmp->tm_mon + 1 ;
913917 _day = tmp->tm_mday ;
914- _wday = tmp->tm_wday + 1 ;
918+ if (tmp->tm_wday == 0 ) {
919+ _wday = RTC_WEEKDAY_SUNDAY;
920+ } else {
921+ _wday = tmp->tm_wday ;
922+ }
915923 _hours = tmp->tm_hour ;
916924 _minutes = tmp->tm_min ;
917925 _seconds = tmp->tm_sec ;
You can’t perform that action at this time.
0 commit comments