aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfarkasdvd <30418389+farkasdvd@users.noreply.github.com>2021-05-25 19:47:50 +0200
committerRobert Tari <robert@tari.in>2021-07-09 03:57:13 +0200
commite4b4a10a52805cc78a351f8b08b56d81d5a42b75 (patch)
treef91ee7f2aacb9dd15aff7379decb7fd50f8f438b /src
parentb584e8ffc67ee1ca07528f742227574aae95a7a3 (diff)
downloadayatana-indicator-datetime-e4b4a10a52805cc78a351f8b08b56d81d5a42b75.tar.gz
ayatana-indicator-datetime-e4b4a10a52805cc78a351f8b08b56d81d5a42b75.tar.bz2
ayatana-indicator-datetime-e4b4a10a52805cc78a351f8b08b56d81d5a42b75.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/planner-snooze.cpp4
1 files changed, 3 insertions, 1 deletions
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::minutes>(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;