Fix bug w/ all day events (hr, min, sec need to be zero in DTSTART)

* For some reason, the recurrence expansion system requires hr, min, and sec
  to be zero for DTSTART when allDay=1
* Force hr, min, and sec to zero for all day events

Bug: 2427658
Change-Id: Ief6b5b571fa6bc6947bcbc9cda02ab2c04f27549
This commit is contained in:
Marc Blank 2010-02-08 09:11:35 -08:00
parent f19a02ac69
commit e81b2bfe5e

View File

@ -52,6 +52,7 @@ import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.StringTokenizer;
import java.util.TimeZone;
@ -360,10 +361,17 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
cv.put(Events.DTEND, endTime);
cv.put(Events.LAST_DATE, endTime);
}
// Set the DURATION using rfc2445
// For all day events, make sure hour, minute, and second are zero for DTSTART
if (allDayEvent != 0) {
cv.put(Events.DURATION, "P1D");
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
cal.setTimeInMillis(startTime);
cal.set(GregorianCalendar.HOUR_OF_DAY, 0);
cal.set(GregorianCalendar.MINUTE, 0);
cal.set(GregorianCalendar.SECOND, 0);
cv.put(Events.DTSTART, cal.getTimeInMillis());
cv.put(Events.ORIGINAL_INSTANCE_TIME, cal.getTimeInMillis());
} else {
cv.put(Events.DURATION, "P" + ((endTime - startTime) / MINUTES) + "M");
}