[svn-commits] twilson: trunk r223449 - /trunk/res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Oct 10 15:02:37 CDT 2009


Author: twilson
Date: Sat Oct 10 15:02:32 2009
New Revision: 223449

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=223449
Log:
Fix handling of floating times and dates

Modified:
    trunk/res/res_calendar_caldav.c
    trunk/res/res_calendar_icalendar.c

Modified: trunk/res/res_calendar_caldav.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_calendar_caldav.c?view=diff&rev=223449&r1=223448&r2=223449
==============================================================================
--- trunk/res/res_calendar_caldav.c (original)
+++ trunk/res/res_calendar_caldav.c Sat Oct 10 15:02:32 2009
@@ -297,6 +297,31 @@
 	return response;
 }
 
+static time_t icalfloat_to_timet(icaltimetype time) 
+{
+	struct ast_tm tm = {0,};
+	struct timeval tv;
+
+	tm.tm_mday = time.day;
+	tm.tm_mon = time.month - 1;
+	tm.tm_year = time.year - 1900;
+	tm.tm_hour = time.hour;
+	tm.tm_min = time.minute;
+	tm.tm_sec = time.second;
+	tm.tm_isdst = -1;
+	tv = ast_mktime(&tm, NULL);
+
+	return tv.tv_sec;
+}
+
+/* span->start & span->end may be dates or floating times which have no timezone,
+ * which would mean that they should apply to the local timezone for all recepients.
+ * For example, if a meeting was set for 1PM-2PM floating time, people in different time
+ * zones would not be scheduled at the same local times.  Dates are often treated as
+ * floating times, so all day events will need to be converted--so we can trust the
+ * span here, and instead will grab the start and end from the component, which will
+ * allow us to test for floating times or dates.
+ */
 static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, void *data)
 {
 	struct caldav_pvt *pvt = data;
@@ -317,11 +342,11 @@
 		return;
 	}
 
-	start = icaltime_from_timet_with_zone(span->start, 0, utc);
-	end = icaltime_from_timet_with_zone(span->end, 0, utc);
-	event->start = span->start;
-	event->end = span->end;
-
+	start = icalcomponent_get_dtstart(comp);
+	end = icalcomponent_get_dtend(comp);
+
+	event->start = icaltime_get_tzid(start) ? span->start : icalfloat_to_timet(start);
+	event->end = icaltime_get_tzid(end) ? span->end : icalfloat_to_timet(end);
 	event->busy_state = span->is_busy ? AST_CALENDAR_BS_BUSY : AST_CALENDAR_BS_FREE;
 
 	if ((prop = icalcomponent_get_first_property(comp, ICAL_SUMMARY_PROPERTY))) {

Modified: trunk/res/res_calendar_icalendar.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_calendar_icalendar.c?view=diff&rev=223449&r1=223448&r2=223449
==============================================================================
--- trunk/res/res_calendar_icalendar.c (original)
+++ trunk/res/res_calendar_icalendar.c Sat Oct 10 15:02:32 2009
@@ -160,6 +160,32 @@
 	return comp;
 }
 
+static time_t icalfloat_to_timet(icaltimetype time) 
+{
+	struct ast_tm tm = {0,};
+	struct timeval tv;
+
+	tm.tm_mday = time.day;
+	tm.tm_mon = time.month - 1;
+	tm.tm_year = time.year - 1900;
+	tm.tm_hour = time.hour;
+	tm.tm_min = time.minute;
+	tm.tm_sec = time.second;
+	tm.tm_isdst = -1;
+	tv = ast_mktime(&tm, NULL);
+
+	return tv.tv_sec;
+}
+
+/* span->start & span->end may be dates or floating times which have no timezone,
+ * which would mean that they should apply to the local timezone for all recepients.
+ * For example, if a meeting was set for 1PM-2PM floating time, people in different time
+ * zones would not be scheduled at the same local times.  Dates are often treated as
+ * floating times, so all day events will need to be converted--so we can trust the
+ * span here, and instead will grab the start and end from the component, which will
+ * allow us to test for floating times or dates.
+ */
+
 static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span, void *data)
 {
 	struct icalendar_pvt *pvt = data;
@@ -180,11 +206,11 @@
 		return;
 	}
 
-	start = icaltime_from_timet_with_zone(span->start, 0, utc);
-	end = icaltime_from_timet_with_zone(span->end, 0, utc);
-	event->start = span->start;
-	event->end = span->end;
-
+	start = icalcomponent_get_dtstart(comp);
+	end = icalcomponent_get_dtend(comp);
+
+	event->start = icaltime_get_tzid(start) ? span->start : icalfloat_to_timet(start);
+	event->end = icaltime_get_tzid(end) ? span->end : icalfloat_to_timet(end);
 	event->busy_state = span->is_busy ? AST_CALENDAR_BS_BUSY : AST_CALENDAR_BS_FREE;
 
 	if ((prop = icalcomponent_get_first_property(comp, ICAL_SUMMARY_PROPERTY))) {




More information about the svn-commits mailing list