From e4b4a10a52805cc78a351f8b08b56d81d5a42b75 Mon Sep 17 00:00:00 2001 From: farkasdvd <30418389+farkasdvd@users.noreply.github.com> Date: Tue, 25 May 2021 19:47:50 +0200 Subject: Snooze starts from the current minute (#30) SnoozePlanner just added the snooze duration to the start of the alarm. If the Snooze button was pressed 10 minutes after the alarm started and the snooze duration is 5 minutes then the alarm is planned into the past. This PR adds every whole minute passed between the start of the alarm and the Snooze action. --- src/planner-snooze.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/planner-snooze.cpp b/src/planner-snooze.cpp index cb365ca..b81c912 100644 --- a/src/planner-snooze.cpp +++ b/src/planner-snooze.cpp @@ -59,7 +59,9 @@ public: appt.alarms.push_back(alarm); // reschedule the alarm to go off N minutes from now - const auto offset = std::chrono::minutes(m_settings->snooze_duration.get()); + // also take into count every whole minute since the alarm went off + const auto offset_to_now = std::chrono::duration_cast(std::chrono::microseconds(DateTime::NowLocal() - appt.begin)); + const auto offset = offset_to_now + std::chrono::minutes(m_settings->snooze_duration.get()); appt.begin += offset; appt.end += offset; appt.alarms[0].time += offset; -- cgit v1.2.3