From 7e61b6213f906bf5da46dffb19a847d37710ddd3 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 2 Oct 2001 14:37:30 +0000 Subject: handle -1 as well (comp_from_remote_record): fix monthly by day 2001-10-02 JP Rosevear * conduits/calendar/calendar-conduit.c (nth_weekday): handle -1 as well (comp_from_remote_record): fix monthly by day recurrences and handle "last" day type svn path=/trunk/; revision=13300 --- calendar/ChangeLog | 7 +++++++ calendar/conduits/calendar/calendar-conduit.c | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index dbb63ec191..d4644fad33 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2001-10-02 JP Rosevear + + * conduits/calendar/calendar-conduit.c (nth_weekday): handle -1 as + well + (comp_from_remote_record): fix monthly by day recurrences and + handle "last" day type + 2001-10-01 Damon Chaplin * gui/dialogs/comp-editor.c (comp_editor_destroy): unref the page diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 0301cbfb90..676d65462c 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -326,9 +326,9 @@ is_empty_time (struct tm time) static short nth_weekday (int pos, icalrecurrencetype_weekday weekday) { - g_assert (pos > 0 && pos <= 5); + g_assert ((pos > 0 && pos <= 5) || (pos == -1)); - return (pos << 3) | (int) weekday; + return ((abs (pos) * 8) + weekday) * (pos < 0 ? -1 : 1); } static GList * @@ -704,7 +704,11 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, case repeatMonthlyByDay: recur.freq = ICAL_MONTHLY_RECURRENCE; recur.interval = appt.repeatFrequency; - recur.by_day[0] = nth_weekday (appt.repeatDay / 5, get_ical_day (appt.repeatDay % 5 - 1)); + if (appt.repeatDay < domLastSun) + recur.by_day[0] = nth_weekday ((appt.repeatDay / 7) + 1, + get_ical_day (appt.repeatDay % 7)); + else + recur.by_day[0] = nth_weekday (-1, get_ical_day (appt.repeatDay % 7)); break; case repeatMonthlyByDate: -- cgit v1.2.3