MCPcopy Create free account
hub / github.com/BruceDevices/firmware / getTimeStruct

Method getTimeStruct

lib/RTC/cplus_RTC.cpp:224–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224struct tm cplus_RTC::getTimeStruct() {
225 RTC_TimeTypeDef timeStruct;
226 RTC_DateTypeDef dateStruct;
227 struct tm timeinfo = {0};
228
229 // Get current time and date from RTC
230 GetTime(&timeStruct);
231 GetDate(&dateStruct);
232
233 // Populate tm structure
234 timeinfo.tm_sec = timeStruct.Seconds;
235 timeinfo.tm_min = timeStruct.Minutes;
236 timeinfo.tm_hour = timeStruct.Hours;
237 timeinfo.tm_mday = dateStruct.Date;
238 timeinfo.tm_mon = dateStruct.Month - 1; // tm_mon is 0-11, RTC month is 1-12
239 timeinfo.tm_year = dateStruct.Year - 1900; // tm_year is years since 1900
240 timeinfo.tm_wday = dateStruct.WeekDay;
241
242 // Calculate day of year
243 mktime(&timeinfo); // This normalizes the struct and calculates tm_yday
244
245 return timeinfo;
246}

Callers 5

drawStatusBarFunction · 0.45
setClockFunction · 0.45
runClockLoopFunction · 0.45
updateClockTimezoneFunction · 0.45
clockCallbackFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected