[gnome-clocks/wip/vala] Alarm: Finish update_alarm_time()
- From: Volker Sobek <vsobek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/wip/vala] Alarm: Finish update_alarm_time()
- Date: Mon, 18 Feb 2013 18:42:45 +0000 (UTC)
commit d4bfeb4adb52808859a95dd578cf94529a72e6db
Author: Volker Sobek <reklov live com>
Date: Mon Feb 18 19:40:47 2013 +0100
Alarm: Finish update_alarm_time()
src/alarm.vala | 17 ++++++++++++-----
src/utils.vala | 6 ++++++
2 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index 2cbeaba..666cb6a 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -120,13 +120,20 @@ private class Item : Object {
minute,
0);
- // check if it can ring later today
- if (dt.compare (now) < 0) {
- dt.add_days (1);
+ if (days.empty) {
+ // Alarm without days.
+ if (dt.compare (now) <= 0) {
+ // Time already passed, ring tomorrow.
+ dt = dt.add_days (1);
+ }
+ } else {
+ // Alarm with at least one day set.
+ // Find the next possible day for ringing
+ while (dt.compare (now) <= 0 || ! days.get ((Utils.Weekdays.Day) (dt.get_day_of_week () -1))) {
+ dt = dt.add_days (1);
+ }
}
- // FIXME: schedule for the next days
-
alarm_time = dt;
}
diff --git a/src/utils.vala b/src/utils.vala
index cf7141e..62d82eb 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -191,6 +191,12 @@ public class Weekdays {
public Weekdays() {
}
+ public bool empty {
+ get {
+ return (days_equal ({false, false, false, false, false, false, false}));
+ }
+ }
+
private bool days_equal (bool[] d) {
assert (d.length == 7);
return (Memory.cmp (d, days, days.length * sizeof (bool)) == 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]