[california] Don't set end date for single-date Quick Add: Bug #735940
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Don't set end date for single-date Quick Add: Bug #735940
- Date: Thu, 4 Sep 2014 01:01:30 +0000 (UTC)
commit 671ada85e778ac97e1248e152c2eec6720b49a2f
Author: Jim Nelson <jim yorba org>
Date: Wed Sep 3 17:58:47 2014 -0700
Don't set end date for single-date Quick Add: Bug #735940
If the user Quick Adds a recurring event by clicking on a date,
prior code would use that date as the start and end date of the event,
which screwed up the RRULE. Now a single day is only treated as
the starting date of the recurring rule.
Additionally, if a date is selected and a weekly recurring event is
Quick Added that starts on a different day of the week, the original
start date is dropped (for consistency). In other words, clicking on
a Wednesday and entering "Meeting every Tuesday" will generate an
RRULE that starts on the upcoming Tuesday.
src/component/component-details-parser.vala | 12 +++++++-
src/tests/tests-quick-add-recurring.vala | 44 +++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/src/component/component-details-parser.vala b/src/component/component-details-parser.vala
index f59b284..e3de8d4 100644
--- a/src/component/component-details-parser.vala
+++ b/src/component/component-details-parser.vala
@@ -143,7 +143,12 @@ public class DetailsParser : BaseObject {
if (event.is_all_day) {
start_date = event.date_span.start_date;
- end_date = event.date_span.end_date;
+
+ // don't set end date if only for one day; this is too greedy, since it's possible
+ // the user merely wanted to set a start date (and the Event object doesn't allow
+ // for that alone)
+ if (!event.date_span.is_same_day)
+ end_date = event.date_span.end_date;
} else if (event.exact_time_span != null) {
start_date = event.exact_time_span.start_date;
start_time = event.exact_time_span.start_exact_time.to_wall_time();
@@ -666,6 +671,11 @@ public class DetailsParser : BaseObject {
// a day of the week
Calendar.DayOfWeek? dow = Calendar.DayOfWeek.parse(unit.casefolded);
if (dow != null) {
+ // if the start date does not match the recurring start date, then clear it (but can't
+ // do this if an end date was set; them's the breaks)
+ if (start_date != null && end_date == null && !start_date.day_of_week.equal_to(dow))
+ start_date = null;
+
Calendar.DayOfWeek[] by_days = iterate<Calendar.DayOfWeek>(dow).to_array();
// if interval is an ordinal, the rule is for "nth day of the month", so it's a position
diff --git a/src/tests/tests-quick-add-recurring.vala b/src/tests/tests-quick-add-recurring.vala
index 2db35d4..9ddab79 100644
--- a/src/tests/tests-quick-add-recurring.vala
+++ b/src/tests/tests-quick-add-recurring.vala
@@ -33,6 +33,8 @@ private class QuickAddRecurring : UnitTest.Harness {
// WEEKLY
add_case("every-tuesday", every_tuesday);
+ add_case("every-tuesday-start-tuesday", every_tuesday_start_tuesday);
+ add_case("every-tuesday-start-wednesday", every_tuesday_start_wednesday);
add_case("every-friday", every_friday);
add_case("every-saturday-until", every_saturday_until);
add_case("all-day-saturday-until", all_day_saturday_until);
@@ -178,8 +180,8 @@ private class QuickAddRecurring : UnitTest.Harness {
// the summary is meeting at work
// the location is work
// the start time is 10am
- private bool basic(string details, out Component.Event event, out string? dump) {
- Component.DetailsParser parser = new Component.DetailsParser(details, null);
+ private bool basic(string details, out Component.Event event, out string? dump, Component.Event? initial
= null) {
+ Component.DetailsParser parser = new Component.DetailsParser(details, null, initial);
event = parser.event;
dump = "%s\n%s".printf(details, event.source);
@@ -314,6 +316,44 @@ private class QuickAddRecurring : UnitTest.Harness {
&& check_byrule_day(event, by_days);
}
+ private bool every_tuesday_start_tuesday(out string? dump) throws Error {
+ Gee.Map<Calendar.DayOfWeek?, int> by_days = iterate<Calendar.DayOfWeek?>(
+ Calendar.DayOfWeek.TUE).to_hash_map_as_keys<int>(dow => 0);
+
+ // A Tuesday
+ Calendar.Date start = new Calendar.Date(Calendar.DayOfMonth.for(2), Calendar.Month.SEP,
+ new Calendar.Year(2014));
+ Component.Event initial = new Component.Event.blank();
+ initial.set_event_date_span(start.to_date_span());
+
+ Component.Event event;
+ return basic("meeting at work at 10am every tuesday", out event, out dump, initial)
+ && event.rrule.is_weekly
+ && event.rrule.interval == 1
+ && !event.rrule.has_duration
+ && event.exact_time_span.start_date.day_of_week.equal_to(Calendar.DayOfWeek.TUE)
+ && check_byrule_day(event, by_days);
+ }
+
+ private bool every_tuesday_start_wednesday(out string? dump) throws Error {
+ Gee.Map<Calendar.DayOfWeek?, int> by_days = iterate<Calendar.DayOfWeek?>(
+ Calendar.DayOfWeek.TUE).to_hash_map_as_keys<int>(dow => 0);
+
+ // A Wednesday
+ Calendar.Date start = new Calendar.Date(Calendar.DayOfMonth.for(3), Calendar.Month.SEP,
+ new Calendar.Year(2014));
+ Component.Event initial = new Component.Event.blank();
+ initial.set_event_date_span(start.to_date_span());
+
+ Component.Event event;
+ return basic("meeting at work at 10am every tuesday", out event, out dump, initial)
+ && event.rrule.is_weekly
+ && event.rrule.interval == 1
+ && !event.rrule.has_duration
+ && event.exact_time_span.start_date.day_of_week.equal_to(Calendar.DayOfWeek.TUE)
+ && check_byrule_day(event, by_days);
+ }
+
private bool every_friday(out string? dump) throws Error {
Gee.Map<Calendar.DayOfWeek?, int> by_days = iterate<Calendar.DayOfWeek?>(
Calendar.DayOfWeek.FRI).to_hash_map_as_keys<int>(dow => 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]