From 78cab3604d307d48db5d2b38b54a00bbaaaf67ec Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Mon, 21 Feb 2022 23:45:59 +0100 Subject: 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. --- src/components/alarm/AlarmController.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/components/alarm/AlarmController.cpp') diff --git a/src/components/alarm/AlarmController.cpp b/src/components/alarm/AlarmController.cpp index 28b328d5..11d96e7a 100644 --- a/src/components/alarm/AlarmController.cpp +++ b/src/components/alarm/AlarmController.cpp @@ -54,7 +54,8 @@ void AlarmController::ScheduleAlarm() { auto now = dateTimeController.CurrentDateTime(); 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(alarmTime)); tm* tmAlarmTime = std::localtime(&ttAlarmTime); // If the time being set has already passed today,the alarm should be set for tomorrow -- cgit v1.2.3