AlarmController: allow loss of precision for alarmTime cast

Allow a loss of precision if the system clock has a lower resolution
than nanoseconds. This is the case for web assembly.
This commit is contained in:
Reinhold Gschweicher 2022-02-21 23:45:59 +01:00
parent 8f436e1d74
commit 78cab3604d

View File

@ -54,7 +54,8 @@ void AlarmController::ScheduleAlarm() {
auto now = dateTimeController.CurrentDateTime(); auto now = dateTimeController.CurrentDateTime();
alarmTime = now; alarmTime = now;
time_t ttAlarmTime = std::chrono::system_clock::to_time_t(alarmTime); time_t ttAlarmTime = std::chrono::system_clock::to_time_t(
std::chrono::time_point_cast<std::chrono::system_clock::duration>(alarmTime));
tm* tmAlarmTime = std::localtime(&ttAlarmTime); tm* tmAlarmTime = std::localtime(&ttAlarmTime);
// If the time being set has already passed today,the alarm should be set for tomorrow // If the time being set has already passed today,the alarm should be set for tomorrow