diff options
Diffstat (limited to 'calendar/pcs')
-rw-r--r-- | calendar/pcs/cal-backend-db.c | 17 | ||||
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 17 |
2 files changed, 24 insertions, 10 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; diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index fdf7eefad1..b7ba095a30 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -1157,7 +1157,11 @@ compute_alarm_range (CalComponent *comp, GList *alarm_uids, time_t start, time_t 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); @@ -1222,10 +1226,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; |