Skip to content

Commit

Permalink
Fixes for RRULE unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
craigk5n committed Aug 28, 2024
1 parent 83cb188 commit cac49bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/main/java/us/k5n/ical/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ public void parseLine(String icalStr, int parseMethod)
String[] dateVals = args[1].split(",");
for (int i = 0; i < dateVals.length; i++) {
String newIcalStr = args[0] + ':' + dateVals[i];
System.out.println("Temp EXDATE str=" + newIcalStr);
Date exdate = new Date(newIcalStr);
this.exdates.add(exdate);
}
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/us/k5n/ical/RruleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,20 @@ public void testYearlyRruleWithMonthlyOccurrences() {
"20030110", "20030210", "20030310" };
String str = "RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=10;BYMONTH=1,2,3";
try {
TimeZone tz = TimeZone.getDefault();
TimeZone tz = TimeZone.getTimeZone("UTC"); // Explicitly set to UTC
String tzid = tz.getID();
Date dtStart = new Date("DTSTART;TZID=" + tzid + ":19970310T090000");
Rrule rrule = new Rrule(str, PARSE_STRICT);
assertNotNull(rrule, "RRULE should not be null");

// This will generate the repeating event dates and does not include the original event date.
// So it should be 9 dates.
List<Date> dates = rrule.generateRecurrances(dtStart, tzid);
assertEquals(9, dates.size());
for (int i = 0; i < dates.size(); i++) {
Date d = dates.get(i);
String ymd = Utils.DateToYYYYMMDD(d);
assertTrue(ymd.equals(expectedResults[i]),
"Unexpected date: got " + ymd + " instead of " + expectedResults[i]);
assertEquals(expectedResults[i+1], ymd);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -186,7 +188,7 @@ public void testYearlyRruleWithElectionDayPattern() {
}
}

//@Test
// @Test
public void testMonthlyRruleWithSecondToLastWeekday() {
String[] expectedResults = { "19970929", "19971030", "19971127", "19971230", "19980129", "19980226",
"19980330" };
Expand Down Expand Up @@ -380,7 +382,7 @@ public void testWeeklyRruleWithRdate() {

List<Date> dates = event.getRecurranceDates();
for (int i = 0; i < dates.size() && i < expectedResults.length; i++) {
System.out.println("Date #" +i+": " + Utils.DateToYYYYMMDD(dates.get(i)));
System.out.println("Date #" + i + ": " + Utils.DateToYYYYMMDD(dates.get(i)));
}
for (int i = 0; i < dates.size() && i < expectedResults.length; i++) {
Date d = dates.get(i);
Expand Down

0 comments on commit cac49bc

Please sign in to comment.