Systemclock and DateTime
General
The three classes Date, Time and DateTime provide the functionality towards a point of time. DateTime combines the features of Date and Time classes.
In contrast to DateTime, the additional class SystemClock represents the date and time information from the Rtc (real time clock).
Initialization of Systemclock
#include "HardwareAbstraction/Stm32/stm32f4rtc.h" #include "Components/System/systemclock.h" #include "main.h" extern RTC_HandleTypeDef hrtc; // CubeMX defines hardware handles in main.c semf::Stm32F4Rtc rtc(hrtc); semf::SystemClock systemclock(rtc);;
Usage
You can set the SystemClock or DateTime object to any time required.
// Setting systemclock to June 1st 2009 10:20:30 and 0 milliseconds systemclock.setDateTime(0, 30, 20, 10, 1, 6, 2009);
Working with DateTime objects you can save, modify and compare timestamps.
// ... semf::DateTime datetime(systemclock); // Initialization of datetime with current timestamp while (1) { if (systemclock.timeSpan(datetime) == 2000) // 2000ms later { datetime = systemclock; // Set dt to the value of Rtc } }