diff options
Diffstat (limited to 'src/com/android/calendarcommon2/RecurrenceSet.java')
-rw-r--r-- | src/com/android/calendarcommon2/RecurrenceSet.java | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/com/android/calendarcommon2/RecurrenceSet.java b/src/com/android/calendarcommon2/RecurrenceSet.java index 86e6a2d..e42c0e9 100644 --- a/src/com/android/calendarcommon2/RecurrenceSet.java +++ b/src/com/android/calendarcommon2/RecurrenceSet.java @@ -20,9 +20,7 @@ import android.content.ContentValues; import android.database.Cursor; import android.provider.CalendarContract; import android.text.TextUtils; -import android.text.format.Time; import android.util.Log; -import android.util.TimeFormatException; import java.util.ArrayList; import java.util.List; @@ -162,14 +160,14 @@ public class RecurrenceSet { // The timezone is updated to UTC if the time string specified 'Z'. try { time.parse(rawDates[i]); - } catch (TimeFormatException e) { + } catch (IllegalArgumentException e) { throw new EventRecurrence.InvalidFormatException( - "TimeFormatException thrown when parsing time " + rawDates[i] + "IllegalArgumentException thrown when parsing time " + rawDates[i] + " in recurrence " + recurrence); } - dates[i] = time.toMillis(false /* use isDst */); - time.timezone = tz; + dates[i] = time.toMillis(); + time.setTimezone(tz); } return dates; } @@ -196,8 +194,9 @@ public class RecurrenceSet { // NOTE: the timezone may be null, if this is a floating time. String tzid = tzidParam == null ? null : tzidParam.value; Time start = new Time(tzidParam == null ? Time.TIMEZONE_UTC : tzid); - boolean inUtc = start.parse(dtstart); - boolean allDay = start.allDay; + start.parse(dtstart); + boolean inUtc = dtstart.length() == 16 && dtstart.charAt(15) == 'Z'; + boolean allDay = start.isAllDay(); // We force TimeZone to UTC for "all day recurring events" as the server is sending no // TimeZone in DTSTART for them @@ -224,9 +223,9 @@ public class RecurrenceSet { } if (allDay) { - start.timezone = Time.TIMEZONE_UTC; + start.setTimezone(Time.TIMEZONE_UTC); } - long millis = start.toMillis(false /* use isDst */); + long millis = start.toMillis(); values.put(CalendarContract.Events.DTSTART, millis); if (millis == -1) { if (false) { @@ -243,7 +242,7 @@ public class RecurrenceSet { values.put(CalendarContract.Events.DURATION, duration); values.put(CalendarContract.Events.ALL_DAY, allDay ? 1 : 0); return true; - } catch (TimeFormatException e) { + } catch (IllegalArgumentException e) { // Something is wrong with the format of this event Log.i(TAG,"Failed to parse event: " + component.toString()); return false; @@ -301,10 +300,10 @@ public class RecurrenceSet { // TODO: android.pim.Time really should take care of this for us. if (allDay) { dtstartProp.addParameter(new ICalendar.Parameter("VALUE", "DATE")); - dtstartTime.allDay = true; - dtstartTime.hour = 0; - dtstartTime.minute = 0; - dtstartTime.second = 0; + dtstartTime.setAllDay(true); + dtstartTime.setHour(0); + dtstartTime.setMinute(0); + dtstartTime.setSecond(0); } dtstartProp.setValue(dtstartTime.format2445()); @@ -360,10 +359,10 @@ public static boolean populateComponent(ContentValues values, // TODO: android.pim.Time really should take care of this for us. if (allDay) { dtstartProp.addParameter(new ICalendar.Parameter("VALUE", "DATE")); - dtstartTime.allDay = true; - dtstartTime.hour = 0; - dtstartTime.minute = 0; - dtstartTime.second = 0; + dtstartTime.setAllDay(true); + dtstartTime.setHour(0); + dtstartTime.setMinute(0); + dtstartTime.setSecond(0); } dtstartProp.setValue(dtstartTime.format2445()); @@ -480,14 +479,13 @@ public static boolean populateComponent(ContentValues values, ICalendar.Parameter endTzidParameter = dtendProperty.getFirstParameter("TZID"); String endTzid = (endTzidParameter == null) - ? start.timezone : endTzidParameter.value; + ? start.getTimezone() : endTzidParameter.value; Time end = new Time(endTzid); end.parse(dtendProperty.getValue()); - long durationMillis = end.toMillis(false /* use isDst */) - - start.toMillis(false /* use isDst */); + long durationMillis = end.toMillis() - start.toMillis(); long durationSeconds = (durationMillis / 1000); - if (start.allDay && (durationSeconds % 86400) == 0) { + if (start.isAllDay() && (durationSeconds % 86400) == 0) { return "P" + (durationSeconds / 86400) + "D"; // Server wants this instead of P86400S } else { return "P" + durationSeconds + "S"; |