]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
* Minor formatting change
[citadel.git] / webcit / event.c
index 2d942aba49fc5658135e9d65ebf76f38b7c6128a..9240884b9ca90b3b481e1cbb2d98bc0bce50b13d 100644 (file)
@@ -71,6 +71,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        if (supplied_vevent != NULL) {
                vevent = supplied_vevent;
+
+               /* Convert all timestamps to UTC to make them easier to process. */
+               ical_dezonify(vevent);
+
                /*
                 * If we're looking at a fully encapsulated VCALENDAR
                 * rather than a VEVENT component, attempt to use the first
@@ -438,15 +442,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wprintf("<table border=0 cellspacing=\"10\" width=100%%>\n");
 
-       /* Table row displaying raw RRULE data, FIXME remove when finished */
-       if (rrule) {
-               wprintf("<tr><td><b>");
-               wprintf("Raw data");
-               wprintf("</b></td><td>");
-               wprintf("<tt>%s</tt>", icalrecurrencetype_as_string(&recur));
-               wprintf("</td></tr>\n");
-       }
-
        char *frequency_units[] = {
                _("seconds"),
                _("minutes"),
@@ -530,9 +525,16 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        );
 
        int rrmday = t_start.day;
-       int rrmweek = 1;                                /* FIXME default to same as event start */
        int rrmweekday = icaltime_day_of_week(t_start) - 1;
 
+       /* Figure out what week of the month we're in */
+       icaltimetype day1 = t_start;
+       day1.day = 1;
+       int weekbase = icaltime_week_number(day1);
+       int rrmweek = icaltime_week_number(t_start) - weekbase + 1;
+
+       /* Are we going by day of the month or week/day? */
+
        if (recur.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
                which_rrmonthtype_is_preselected = 0;
                rrmday = recur.by_month_day[0];
@@ -581,10 +583,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wprintf("</div>\n");                            /* end 'monthday_selector' div */
 
 
-       int rrymweek = 1;                               /* FIXME default to same as event start */
-       int rrymweekday = 1;                            /* FIXME default to same as event start */
-       int rrymonth = 1;                               /* FIXME default to same as event start */
-
+       int rrymweek = rrmweek;
+       int rrymweekday = rrmweekday;
+       int rrymonth = t_start.month;
        int which_rryeartype_is_preselected = 0;
 
        if ( (recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) 
@@ -759,6 +760,10 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
 
        if (supplied_vevent != NULL) {
                vevent = supplied_vevent;
+
+               /* Convert all timestamps to UTC to make them easier to process. */
+               ical_dezonify(vevent);
+
                /*
                 * If we're looking at a fully encapsulated VCALENDAR
                 * rather than a VEVENT component, attempt to use the first
@@ -840,16 +845,10 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        icaltime_from_webform(&event_start, "dtstart");
                }
 
-               /*
-                * The following odd-looking snippet of code looks like it
-                * takes some unnecessary steps.  It is done this way because
-                * libical incorrectly turns an "all day event" into a normal
-                * event starting at midnight (i.e. it serializes as date/time
-                * instead of just date) unless icalvalue_new_date() is used.
-                * So we force it, if this is an all day event.
-                */
                prop = icalproperty_new_dtstart(event_start);
+
                if (all_day_event) {
+                       /* Force it to serialize as a date-only rather than date/time */
                        icalproperty_set_value(prop, icalvalue_new_date(event_start));
                }
 
@@ -922,11 +921,23 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                                                recur.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
                                        }
                                        else if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_wday")) {
-                                               lprintf(9, "MONTHLY BY WDAY\n");
+                                               recur.by_day[0] = (atoi(bstr("rrmweek")) * 8)
+                                                               + atoi(bstr("rrmweekday")) + 1;
+                                               recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
                                        }
                                        break;
 
                                case ICAL_YEARLY_RECURRENCE:
+                                       if (!strcasecmp(bstr("rryeartype"), "rryeartype_ymday")) {
+                                               /* no further action is needed here */
+                                       }
+                                       else if (!strcasecmp(bstr("rryeartype"), "rryeartype_ywday")) {
+                                               recur.by_month[0] = atoi(bstr("rrymonth"));
+                                               recur.by_month[1] = ICAL_RECURRENCE_ARRAY_MAX;
+                                               recur.by_day[0] = (atoi(bstr("rrymweek")) * 8)
+                                                               + atoi(bstr("rrymweekday")) + 1;
+                                               recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+                                       }
                                        break;
 
                                /* This one can't happen either. */