From 853910579e481fefc80447cefe36e54ba5c38f57 Mon Sep 17 00:00:00 2001 From: Ruffalo Lavoisier Date: Sun, 12 Jan 2025 19:50:26 +0900 Subject: [PATCH 1/2] services: fix casting on toast --- src/services/OswServiceTaskNotifier.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/OswServiceTaskNotifier.cpp b/src/services/OswServiceTaskNotifier.cpp index d0902bd90..2ea9e73fb 100644 --- a/src/services/OswServiceTaskNotifier.cpp +++ b/src/services/OswServiceTaskNotifier.cpp @@ -82,9 +82,10 @@ void OswServiceTaskNotifier::setup() { void OswServiceTaskNotifier::loop() { const std::lock_guard lock{mutlimapMutex}; auto utcTime = std::chrono::system_clock::from_time_t(OswHal::getInstance()->getUTCTime()); - auto currentTime = utcTime + std::chrono::seconds{static_cast(OswHal::getInstance()->getTimezoneOffsetPrimary())}; + auto utcTimeInSeconds = std::chrono::duration_cast(utcTime.time_since_epoch()); + auto currentTime = utcTimeInSeconds + std::chrono::seconds{static_cast(OswHal::getInstance()->getTimezoneOffsetPrimary())}; if (auto it = scheduler.begin(); - it != scheduler.end() && currentTime >= it->first) { + it != scheduler.end() && currentTime.count() >= it->first.time_since_epoch().count()) { auto timeToFire = it->first; const auto& notification = it->second; #ifdef OSW_EMULATOR From 47066161c5f7aee5bc4632f432daf8f5e0d0072f Mon Sep 17 00:00:00 2001 From: Ruffalo Lavoisier Date: Sun, 12 Jan 2025 20:37:47 +0900 Subject: [PATCH 2/2] services: fix casting another code --- src/services/OswServiceTaskNotifier.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/OswServiceTaskNotifier.cpp b/src/services/OswServiceTaskNotifier.cpp index 2ea9e73fb..63fe78c39 100644 --- a/src/services/OswServiceTaskNotifier.cpp +++ b/src/services/OswServiceTaskNotifier.cpp @@ -13,11 +13,12 @@ NotificationData OswServiceTaskNotifier::createNotification(std::chrono::time_po std::chrono::time_point getTimeToFire(int hours, int minutes) { auto utcTime = std::chrono::system_clock::from_time_t(OswHal::getInstance()->getUTCTime()); - auto currentTime = utcTime + std::chrono::seconds{static_cast(OswHal::getInstance()->getTimezoneOffsetPrimary())}; + auto utcTimeInSeconds = std::chrono::duration_cast(utcTime.time_since_epoch()); + auto currentTime = utcTimeInSeconds + std::chrono::seconds{static_cast(OswHal::getInstance()->getTimezoneOffsetPrimary())}; auto currentDate = date::sys_days(floor(currentTime)); auto scheduledTime = std::chrono::hours{hours} + std::chrono::minutes{minutes} + std::chrono::seconds{0}; auto timeToFire = currentDate + scheduledTime; - if (currentTime >= timeToFire) { + if (currentTime.count() >= timeToFire.time_since_epoch().count()) { timeToFire += date::days{1}; } return timeToFire;