]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
* add conditional to check room-types
[citadel.git] / webcit / event.c
index 9b54b6dfc35851b48e25364506234e3d1eed6f18..9f7bdfc2b4dbb9c59c17d7ac791fd61b0f2afe07 100644 (file)
@@ -225,22 +225,30 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wprintf("</TD></TR>\n");
 
-       /*
-        * If this is an all-day-event, set the end time to be identical to
-        * the start time (the hour/minute/second will be set to midnight).
-        * Otherwise extract or create it.
-        */
        wprintf("<TR><TD><B>");
        wprintf(_("End"));
        wprintf("</B></TD><TD id=\"dtendcell\">\n");
-       if (t_start.is_date) {
-               t_end = t_start;
+       p = icalcomponent_get_first_property(vevent,
+                                               ICAL_DTEND_PROPERTY);
+       if (p != NULL) {
+               t_end = icalproperty_get_dtend(p);
+               
+               /*
+                * If this is an all-day-event, the end time is set to real end
+                * day + 1, so we have to adjust accordingly. 
+                */
+               if (t_start.is_date) {
+                       icaltime_adjust(&t_end, -1, 0, 0, 0);
+               }
        }
        else {
-               p = icalcomponent_get_first_property(vevent,
-                                                       ICAL_DTEND_PROPERTY);
-               if (p != NULL) {
-                       t_end = icalproperty_get_dtend(p);
+               /*
+                * If this is an all-day-event, set the end time to be identical to
+                * the start time (the hour/minute/second will be set to midnight).
+                * Otherwise extract or create it.
+                */
+               if (t_start.is_date) {
+                       t_end = t_start;
                }
                else {
                        /*
@@ -871,14 +879,21 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        icalproperty_free(prop);
                }
 
-               if (all_day_event == 0) {
+               if (all_day_event) {
+                       icaltime_from_webform_dateonly(&t, "dtend");    
+
+                       /* with this field supposed to be non-inclusive we have to add one day */
+                       icaltime_adjust(&t, 1, 0, 0, 0);
+               }
+               else {
                        icaltime_from_webform(&t, "dtend");     
-                       icalcomponent_add_property(vevent,
-                               icalproperty_new_dtend(icaltime_normalize(t)
-                               )
-                       );
                }
 
+               icalcomponent_add_property(vevent,
+                       icalproperty_new_dtend(icaltime_normalize(t)
+                       )
+               );
+
                /* recurrence rules -- begin */
 
                /* remove any existing rule */