[evolution-patches] Patch for e-d-s calendar recurrence handling



Hi, Harish and Chen,

    We find a problem in generate_instance() again. If an event is using
a timezone only known by the backend server which is not in the builtin
timezone list, the displayed event's time in dayview will be wrong.
    So for a given tzid, we need try to reslove it from backend if
needed. The logic in e_cal_recur_generate_instances_of_rule() is
correct, so I copied the code from there to fix the problem.

    Please review the patch. Thanks!
       Harry

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.510.2.5
diff -u -r1.510.2.5 ChangeLog
--- ChangeLog	29 Sep 2005 11:59:30 -0000	1.510.2.5
+++ ChangeLog	30 Sep 2005 06:49:14 -0000
@@ -1,3 +1,9 @@
+2005-09-30  Harry Lu <harry lu sun com>
+
+	* libecal/e-cal.c: (generate_instances): use the same logic as in
+	e_cal_recur_generate_instances_of_rule() to get the instance's
+	start and end time.
+
 2005-09-29  Dinesh Layek  <ldinesh novell com>
 
 	Fixes #309679
Index: libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.113.2.2
diff -u -r1.113.2.2 e-cal.c
--- libecal/e-cal.c	28 Sep 2005 13:16:46 -0000	1.113.2.2
+++ libecal/e-cal.c	30 Sep 2005 06:49:24 -0000
@@ -3572,23 +3572,45 @@
 		comp = l->data;
 		if (e_cal_component_is_instance (comp)) {
 			struct comp_instance *ci;
-			struct icaltimetype start_time, end_time;
+			ECalComponentDateTime dtstart, dtend;
+			icaltimezone *start_zone = NULL, *end_zone = NULL;
 
 			/* keep the detached instances apart */
 			ci = g_new0 (struct comp_instance, 1);
 			ci->comp = comp;
-	
-			start_time = icalcomponent_get_dtstart (e_cal_component_get_icalcomponent (comp));
-			end_time = icalcomponent_get_dtend (e_cal_component_get_icalcomponent (comp));
-
-			if (icaltime_is_date (start_time))
-				start_time.zone = default_zone;
-			if (icaltime_is_date (end_time))
-				end_time.zone = default_zone;
-
-			ci->start = icaltime_as_timet_with_zone (start_time, start_time.zone);
-			ci->end = icaltime_as_timet_with_zone (end_time, end_time.zone);
-			
+
+			e_cal_component_get_dtstart (comp, &dtstart);
+			e_cal_component_get_dtend (comp, &dtend);
+
+			/* For DATE-TIME values with a TZID, we use 
+			e_cal_resolve_tzid_cb to resolve the TZID. 
+			For DATE values and DATE-TIME values without a
+			TZID (i.e. floating times) we use the default 
+			timezone. */
+			if (dtstart.tzid && !dtstart.value->is_date) {
+				start_zone = e_cal_resolve_tzid_cb (dtstart.tzid, ecal);
+				if (!start_zone)
+					start_zone = default_zone;
+			} else {
+				start_zone = default_zone;
+			}
+
+			if (dtend.tzid && !dtend.value->is_date) {
+				end_zone = e_cal_resolve_tzid_cb (dtend.tzid, ecal);
+				if (!end_zone)
+					end_zone = default_zone;
+			} else {
+				end_zone = default_zone;
+			}
+
+			ci->start = icaltime_as_timet_with_zone (*dtstart.value,
+							start_zone);
+			ci->end = icaltime_as_timet_with_zone (*dtend.value,
+						   	end_zone);
+
+			e_cal_component_free_datetime (&dtstart);
+			e_cal_component_free_datetime (&dtend);
+ 
 			detached_instances = g_list_prepend (detached_instances, ci);
 		} else {
 			e_cal_recur_generate_instances (comp, start, end, add_instance, &instances,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]