[Xfce4-commits] r25381 - in xfcalendar/branches/xfce_4_4: libical/src/libical src
Juha Kautto
juha at xfce.org
Wed Apr 4 20:35:51 CEST 2007
Author: juha
Date: 2007-04-04 18:35:50 +0000 (Wed, 04 Apr 2007)
New Revision: 25381
Modified:
xfcalendar/branches/xfce_4_4/libical/src/libical/icaltime.c
xfcalendar/branches/xfce_4_4/src/ical-code.c
Log:
Bug 3058 - Bug when adding All day event from iCal
All day events were handled wrongly in Orage.
Modified: xfcalendar/branches/xfce_4_4/libical/src/libical/icaltime.c
===================================================================
--- xfcalendar/branches/xfce_4_4/libical/src/libical/icaltime.c 2007-04-04 15:58:55 UTC (rev 25380)
+++ xfcalendar/branches/xfce_4_4/libical/src/libical/icaltime.c 2007-04-04 18:35:50 UTC (rev 25381)
@@ -25,6 +25,8 @@
2006-09-04 Added support for WKST = weekstart day **Juha
based on CVS code
+ 2007-01-10 fixed icaltime_add by fixing icaltime_adjust **Juha
+
======================================================================*/
#ifdef HAVE_CONFIG_H
@@ -783,8 +785,12 @@
int days_in_month;
/* If we are passed a date make sure to ignore hour minute and second */
+ /* JK: fix part1: this function is called by icaltime_add, which uses
+ * only seconds even for date and adding days does not work */
+ /*
if (tt->is_date)
goto IS_DATE;
+ */
/* Add on the seconds. */
second = tt->second + seconds;
@@ -813,6 +819,16 @@
days_overflow--;
}
+ /* If we are passed a date make sure to ignore hour minute and second */
+ /* JK: fix part2: this function is called by icaltime_add, which uses
+ * only seconds even for date and adding days does not work. we need
+ * however make sure time part is zero */
+ if (tt->is_date) {
+ tt->second = 0;
+ tt->minute = 0;
+ tt->hour = 0;
+ }
+
IS_DATE:
/* Normalize the month. We do this before handling the day since we may
need to know what month it is to get the number of days in it.
Modified: xfcalendar/branches/xfce_4_4/src/ical-code.c
===================================================================
--- xfcalendar/branches/xfce_4_4/src/ical-code.c 2007-04-04 15:58:55 UTC (rev 25380)
+++ xfcalendar/branches/xfce_4_4/src/ical-code.c 2007-04-04 18:35:50 UTC (rev 25381)
@@ -753,6 +753,8 @@
{
icalproperty *p;
xfical_period per;
+ struct icaldurationtype duration_tmp;
+ gint dur_int;
/* Exactly one start time must be there */
p = icalcomponent_get_first_property(c_event, ICAL_DTSTART_PROPERTY);
@@ -772,6 +774,16 @@
per.etime = icalproperty_get_dtend(p);
per.etime = convert_to_local_timezone(per.etime, p);
per.duration = icaltime_subtract(per.etime, per.stime);
+ if (icaltime_is_date(per.stime)
+ && icaldurationtype_as_int(per.duration) != 0) {
+ /* need to subtract 1 day.
+ * read explanation from appt_add_internal: appt->endtime processing */
+ duration_tmp = icaldurationtype_from_int(60*60*24);
+ dur_int = icaldurationtype_as_int(per.duration);
+ dur_int -= icaldurationtype_as_int(duration_tmp);
+ per.duration = icaldurationtype_from_int(dur_int);
+ per.etime = icaltime_add(per.stime, per.duration);
+ }
}
else {
p = icalcomponent_get_first_property(c_event, ICAL_DURATION_PROPERTY);
@@ -1303,7 +1315,11 @@
if XFICAL_STR_EXISTS(appt->starttime) {
wtime=icaltime_from_string(appt->starttime);
- if XFICAL_STR_EXISTS(appt->start_tz_loc) {
+ if (appt->allDay) { /* date */
+ icalcomponent_add_property(ievent
+ , icalproperty_new_dtstart(wtime));
+ }
+ else if XFICAL_STR_EXISTS(appt->start_tz_loc) {
if (strcmp(appt->start_tz_loc, "UTC") == 0) {
wtime=icaltime_convert_to_zone(wtime, utc_icaltimezone);
icalcomponent_add_property(ievent
@@ -1332,7 +1348,15 @@
}
else if XFICAL_STR_EXISTS(appt->endtime) {
wtime=icaltime_from_string(appt->endtime);
- if XFICAL_STR_EXISTS(appt->end_tz_loc) {
+ if (appt->allDay) {
+ /* need to add 1 day. For example:
+ * DTSTART=20070221 & DTEND=20070223
+ * means only 21 and 22 February */
+ duration = icaldurationtype_from_int(60*60*24);
+ wtime = icaltime_add(wtime, duration);
+ icalcomponent_add_property(ievent, icalproperty_new_dtend(wtime));
+ }
+ else if XFICAL_STR_EXISTS(appt->end_tz_loc) {
if (strcmp(appt->end_tz_loc, "UTC") == 0) {
wtime=icaltime_convert_to_zone(wtime, utc_icaltimezone);
icalcomponent_add_property(ievent
@@ -1526,7 +1550,7 @@
icalparameter *itime_tz;
icalproperty_transp xf_transp;
struct icalrecurrencetype rrule;
- struct icaldurationtype duration;
+ struct icaldurationtype duration, duration_tmp;
int i, cnt, day;
for (c = icalcomponent_get_first_component(ical, ICAL_VEVENT_COMPONENT);
@@ -1732,19 +1756,30 @@
}
}
+ if (key_found) {
/* need to set missing endtime or duration */
- if (appt.use_duration) {
- etime = icaltime_add(stime, duration);
- text = icaltime_as_ical_string(etime);
- g_strlcpy(appt.endtime, text, 17);
- appt.end_tz_loc = appt.start_tz_loc;
+ if (appt.use_duration) {
+ etime = icaltime_add(stime, duration);
+ text = icaltime_as_ical_string(etime);
+ g_strlcpy(appt.endtime, text, 17);
+ appt.end_tz_loc = appt.start_tz_loc;
+ }
+ else {
+ duration = icaltime_subtract(eltime, sltime);
+ appt.duration = icaldurationtype_as_int(duration);
+ if (appt.allDay && appt.duration) {
+ /* need to subtract 1 day.
+ * read explanation from appt_add_internal: appt->endtime processing */
+ duration_tmp = icaldurationtype_from_int(60*60*24);
+ appt.duration -= icaldurationtype_as_int(duration_tmp);
+ duration = icaldurationtype_from_int(appt.duration);
+ etime = icaltime_add(stime, duration);
+ text = icaltime_as_ical_string(etime);
+ g_strlcpy(appt.endtime, text, 17);
+ }
+ }
+ return(&appt);
}
- else {
- duration = icaltime_subtract(eltime, sltime);
- appt.duration = icaldurationtype_as_int(duration);
- }
- if (key_found)
- return(&appt);
else
return(NULL);
}
More information about the Xfce4-commits
mailing list