aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/calendarcommon/RecurrenceSet.java14
-rw-r--r--tests/src/com/android/calendarcommon/RecurrenceSetTest.java44
2 files changed, 51 insertions, 7 deletions
diff --git a/src/com/android/calendarcommon/RecurrenceSet.java b/src/com/android/calendarcommon/RecurrenceSet.java
index 2c6200f..426238f 100644
--- a/src/com/android/calendarcommon/RecurrenceSet.java
+++ b/src/com/android/calendarcommon/RecurrenceSet.java
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
*/
public class RecurrenceSet {
- private final static String TAG = "CalendarProvider";
+ private final static String TAG = "RecurrenceSet";
private final static String RULE_SEPARATOR = "\n";
private final static String FOLDING_SEPARATOR = "\n ";
@@ -185,7 +185,7 @@ public class RecurrenceSet {
if (inUtc || allDay) {
tzid = Time.TIMEZONE_UTC;
}
-
+
String duration = computeDuration(start, component);
String rrule = flattenProperties(component, "RRULE");
String rdate = extractDates(component.getFirstProperty("RDATE"));
@@ -203,7 +203,7 @@ public class RecurrenceSet {
}
return false;
}
-
+
if (allDay) {
start.timezone = Time.TIMEZONE_UTC;
}
@@ -215,7 +215,7 @@ public class RecurrenceSet {
}
return false;
}
-
+
values.put(CalendarContract.Events.RRULE, rrule);
values.put(CalendarContract.Events.RDATE, rdate);
values.put(CalendarContract.Events.EXRULE, exrule);
@@ -229,7 +229,7 @@ public class RecurrenceSet {
// This can be removed when the old CalendarSyncAdapter is removed.
public static boolean populateComponent(Cursor cursor,
ICalendar.Component component) {
-
+
int dtstartColumn = cursor.getColumnIndex(CalendarContract.Events.DTSTART);
int durationColumn = cursor.getColumnIndex(CalendarContract.Events.DURATION);
int tzidColumn = cursor.getColumnIndex(CalendarContract.Events.EVENT_TIMEZONE);
@@ -271,7 +271,7 @@ public class RecurrenceSet {
// use the "floating" timezone
dtstartTime = new Time(Time.TIMEZONE_UTC);
}
-
+
dtstartTime.set(dtstart);
// make sure the time is printed just as a date, if all day.
// TODO: android.pim.Time really should take care of this for us.
@@ -435,7 +435,7 @@ public static boolean populateComponent(ContentValues values,
prop.setValue(dateStr);
component.addProperty(prop);
}
-
+
private static String computeDuration(Time start,
ICalendar.Component component) {
// see if a duration is defined
diff --git a/tests/src/com/android/calendarcommon/RecurrenceSetTest.java b/tests/src/com/android/calendarcommon/RecurrenceSetTest.java
index 8382db8..5b29fc3 100644
--- a/tests/src/com/android/calendarcommon/RecurrenceSetTest.java
+++ b/tests/src/com/android/calendarcommon/RecurrenceSetTest.java
@@ -59,6 +59,50 @@ public class RecurrenceSetTest extends TestCase {
null, null, 1250812800000L, "UTC", "P2D", 1);
}
+ // Test multi-rule RRULE.
+ @SmallTest
+ public void testRecurrenceSet3() throws Exception {
+ String recurrence = "DTSTART;VALUE=DATE:20090821\n"
+ + "RRULE:FREQ=YEARLY;WKST=SU\n"
+ + "RRULE:FREQ=MONTHLY;COUNT=3\n"
+ + "DURATION:P2H";
+ verifyPopulateContentValues(recurrence, "FREQ=YEARLY;WKST=SU\nFREQ=MONTHLY;COUNT=3", null,
+ null, null, 1250812800000L, "UTC", "P2H", 1 /*allDay*/);
+ // allDay=1 just means the start time is 00:00:00 UTC.
+ }
+
+ // Test RDATE with VALUE=DATE.
+ @SmallTest
+ public void testRecurrenceSet4() throws Exception {
+ String recurrence = "DTSTART;TZID=America/Los_Angeles:20090821T010203\n"
+ + "RDATE;TZID=America/Los_Angeles;VALUE=DATE:20110601,20110602,20110603\n"
+ + "DURATION:P2H";
+ verifyPopulateContentValues(recurrence, null,
+ //"TZID=America/Los_Angeles;VALUE=DATE:20110601,20110602,20110603",
+ "America/Los_Angeles;20110601,20110602,20110603", // incorrect
+ null, null, 1250841723000L, "America/Los_Angeles", "P2H", 0 /*allDay*/);
+ // allDay=1 just means the start time is 00:00:00 UTC.
+ }
+
+ // Check generation of duration from events in different time zones.
+ @SmallTest
+ public void testRecurrenceSet5() throws Exception {
+ String recurrence = "DTSTART;TZID=America/Los_Angeles:20090821T070000\n"
+ + "DTEND;TZID=America/New_York:20090821T110000\n"
+ + "RRULE:FREQ=YEARLY\n";
+ verifyPopulateContentValues(recurrence, "FREQ=YEARLY", null,
+ null, null, 1250863200000L, "America/Los_Angeles", "P3600S" /*P1H*/, 0 /*allDay*/);
+ // TODO: would like to use P1H for duration
+
+ String recurrence2 = "DTSTART;TZID=America/New_York:20090821T100000\n"
+ + "DTEND;TZID=America/Los_Angeles:20090821T080000\n"
+ + "RRULE:FREQ=YEARLY\n";
+ verifyPopulateContentValues(recurrence, "FREQ=YEARLY", null,
+ null, null, 1250863200000L, "America/Los_Angeles", "P3600S" /*P1H*/, 0 /*allDay*/);
+ // TODO: should we rigorously define which tzid becomes the "event timezone"?
+ }
+
+
// run populateContentValues and verify the results
private void verifyPopulateContentValues(String recurrence, String rrule, String rdate,
String exrule, String exdate, long dtstart, String tzid, String duration, int allDay)