[california] Properly adjust start/end date when RRULE updated
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Properly adjust start/end date when RRULE updated
- Date: Wed, 24 Sep 2014 22:31:14 +0000 (UTC)
commit 39482e8216e6b7a88da61e217216eba45c6ac9d1
Author: Jim Nelson <jim yorba org>
Date: Wed Sep 24 15:23:35 2014 -0700
Properly adjust start/end date when RRULE updated
src/component/component-event.vala | 17 +++++++++++++----
src/host/host-create-update-recurring.vala | 6 +++---
2 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index ed3e2ed..1ead71e 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -294,22 +294,31 @@ public class Event : Instance, Gee.Comparable<Event> {
* { link set_event_exact_time_span} but without the hassle of preserving start and end times
* while changing the dates.
*/
- public void adjust_event_date_span(Calendar.DateSpan date_span) {
+ public void adjust_start_date(Calendar.Date new_start_date) {
+ // generate a new end date that is the same chronological distance from the original start
+ // date
+ Calendar.DateSpan orig_dates = get_event_date_span(null);
+ int diff = orig_dates.start_date.difference(new_start_date);
+ if (diff == 0)
+ return;
+
+ Calendar.Date new_end_date = orig_dates.end_date.adjust(diff);
+
if (is_all_day) {
- set_event_date_span(date_span);
+ set_event_date_span(new Calendar.DateSpan(new_start_date, new_end_date));
return;
}
Calendar.ExactTime new_start_time = new Calendar.ExactTime(
exact_time_span.start_exact_time.tz,
- date_span.start_date,
+ new_start_date,
exact_time_span.start_exact_time.to_wall_time()
);
Calendar.ExactTime new_end_time = new Calendar.ExactTime(
exact_time_span.end_exact_time.tz,
- date_span.end_date,
+ new_end_date,
exact_time_span.end_exact_time.to_wall_time()
);
diff --git a/src/host/host-create-update-recurring.vala b/src/host/host-create-update-recurring.vala
index 86ab149..a81b7fa 100644
--- a/src/host/host-create-update-recurring.vala
+++ b/src/host/host-create-update-recurring.vala
@@ -571,15 +571,15 @@ public class CreateUpdateRecurring : Gtk.Grid, Toolkit.Card {
// set start and end dates (which may actually be date-times, so use adjust)
if (never_radiobutton.active) {
// no duration
- master.adjust_event_date_span(start_date.to_date_span());
+ master.adjust_start_date(start_date);
rrule.set_recurrence_end_date(null);
} else if (ends_on_radiobutton.active) {
- master.adjust_event_date_span(new Calendar.DateSpan(start_date, end_date));
+ master.adjust_start_date(start_date);
rrule.set_recurrence_end_date(end_date);
} else {
assert(after_radiobutton.active);
- master.adjust_event_date_span(start_date.to_date_span());
+ master.adjust_start_date(start_date);
rrule.set_recurrence_count(Numeric.floor_int(int.parse(after_entry.text), 1));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]