libical r647 - in trunk: . src/libical
- From: pchen svn gnome org
- To: svn-commits-list gnome org
- Subject: libical r647 - in trunk: . src/libical
- Date: Mon, 1 Sep 2008 08:56:37 +0000 (UTC)
Author: pchen
Date: Mon Sep 1 08:56:37 2008
New Revision: 647
URL: http://svn.gnome.org/viewvc/libical?rev=647&view=rev
Log:
Fixes #548268.
Modified:
trunk/ChangeLog
trunk/src/libical/icaltz-util.c
Modified: trunk/src/libical/icaltz-util.c
==============================================================================
--- trunk/src/libical/icaltz-util.c (original)
+++ trunk/src/libical/icaltz-util.c Mon Sep 1 08:56:37 2008
@@ -198,6 +198,21 @@
return zdir;
}
+/* Calculate the relative position of the week in a month from a date */
+static int
+calculate_pos (icaltimetype icaltime)
+{
+ int pos;
+
+ pos = (icaltime.day -1) / 7;
+
+ /* Check if pos 3 is the last occurence of the week day in the month */
+ if (pos == 3 && ((icaltime.day + 7) > icaltime_days_in_month (icaltime.month, icaltime.year)))
+ pos = 4;
+
+ return r_pos [pos];
+}
+
icalcomponent*
icaltzutil_fetch_timezone (const char *location)
{
@@ -349,7 +364,7 @@
icalrecurrencetype_clear (&ical_recur);
ical_recur.freq = ICAL_YEARLY_RECURRENCE;
ical_recur.by_month [0] = icaltime.month;
- pos = r_pos [icaltime.day/7];
+ pos = calculate_pos (icaltime);
pos < 0 ? (sign = -1): (sign = 1);
ical_recur.by_day [0] = sign * ((abs (pos) * 8) + icaltime_day_of_week (icaltime));
icalprop = icalproperty_new_rrule (ical_recur);
@@ -387,7 +402,7 @@
icalrecurrencetype_clear (&ical_recur);
ical_recur.freq = ICAL_YEARLY_RECURRENCE;
ical_recur.by_month [0] = icaltime.month;
- pos = r_pos [icaltime.day/7];
+ pos = calculate_pos (icaltime);
pos < 0 ? (sign = -1): (sign = 1);
ical_recur.by_day [0] = sign * ((abs (pos) * 8) + icaltime_day_of_week (icaltime));
icalprop = icalproperty_new_rrule (ical_recur);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]