semf
ClockAndDateTime

General

The three classes semf::Date, semf::Time and semf::DateTime provide time and date related functionality. semf::DateTime combines the features of semf::Date and semf::Time classes.

In contrast to semf::DateTime the additional class semf::app::Clock represents the date and time information from the semf::Rtc (real time clock).

Initialization of Clock

#include "semf/utils/system/clock.h"
#include "main.h"
extern RTC_HandleTypeDef hrtc; // CubeMX defines hardware handles in main.c
semf::Stm32F4Rtc rtc(hrtc);
semf::Clock clock(rtc);;
The Clock class provides real time clock functionality. It can return a DateTime object with actual d...
Definition: clock.h:22

Usage

You can set the semf::app::Clock or semf::DateTime object to any time required.

// Setting clock to June 1st 2009 10:20:30 and 0 milliseconds
clock.setDateTime(0, 30, 20, 10, 1, 6, 2009);

Working with semf::DateTime objects you can save, modify and compare timestamps.

// ...
semf::DateTime datetime(clock); // Initialization of datetime with current timestamp
while (1)
{
if (clock.timeSpan(datetime) == 2000) // 2000ms later
{
datetime = clock; // Set dt to the value of Rtc
}
}
The DateTime class provides date and time functionality as a point of time. It combines features of t...
Definition: datetime.h:31