diff options
Diffstat (limited to 'calendar/pcs/cal-backend-db.c')
-rw-r--r-- | calendar/pcs/cal-backend-db.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/calendar/pcs/cal-backend-db.c b/calendar/pcs/cal-backend-db.c index 56b9786c0d..73aef5d054 100644 --- a/calendar/pcs/cal-backend-db.c +++ b/calendar/pcs/cal-backend-db.c @@ -998,7 +998,11 @@ compute_alarm_range (CalComponent *comp, dur_time = icaldurationtype_as_int (*dur); if (dur->is_neg) - *alarm_end = MAX (*alarm_end, end + dur_time); + /* If the duration is negative then dur_time + * will be negative as well; that is why we + * subtract to expand the range. + */ + *alarm_end = MAX (*alarm_end, end - dur_time); else *alarm_start = MIN (*alarm_start, start - dur_time); @@ -1062,10 +1066,13 @@ add_alarm_occurrences_cb (CalComponent *comp, time_t start, time_t end, gpointer else occur_time = end; - if (dur->is_neg) - trigger_time = occur_time - dur_time; - else - trigger_time = occur_time + dur_time; + /* If dur->is_neg is true then dur_time will already be + * negative. So we do not need to test for dur->is_neg here; we + * can simply add the dur_time value to the occur_time and get + * the correct result. + */ + + trigger_time = occur_time + dur_time; if (trigger_time < aod->start || trigger_time >= aod->end) continue; |