Refactoring

This commit is contained in:
M66B 2023-10-25 16:37:36 +02:00
parent 01d1b1070c
commit cb94d4d6ca
1 changed files with 11 additions and 8 deletions

View File

@ -118,11 +118,18 @@ public class CalendarHelper {
ICalDate start = (event.getDateStart() == null ? null : event.getDateStart().getValue());
ICalDate end = (event.getDateEnd() == null ? null : event.getDateEnd().getValue());
TimezoneInfo tzinfo = icalendar.getTimezoneInfo();
TimezoneAssignment tza = (tzinfo == null ? null : tzinfo.getTimezone(event.getDateStart()));
TimeZone tz = (tza == null ? null : tza.getTimeZone());
//if (tz != null && "W. Europe Standard Time".equals(tz.getID()))
// tz.setID("GMT");
String tzid = (tz == null ? TimeZone.getDefault().getID() : tz.getID());
String rrule = null;
RecurrenceRule recurrence = event.getRecurrenceRule();
if (recurrence != null) {
RecurrenceRuleScribe scribe = new RecurrenceRuleScribe();
WriteContext wcontext = new WriteContext(ICalVersion.V2_0, icalendar.getTimezoneInfo(), null);
WriteContext wcontext = new WriteContext(ICalVersion.V2_0, tzinfo, null);
rrule = scribe.writeText(recurrence, wcontext);
}
@ -163,11 +170,7 @@ public class CalendarHelper {
values.put(CalendarContract.Events.ORGANIZER, organizer);
// Assume one time zone
TimezoneInfo tzinfo = icalendar.getTimezoneInfo();
TimezoneAssignment tza = (tzinfo == null ? null : tzinfo.getTimezone(event.getDateStart()));
TimeZone tz = (tza == null ? null : tza.getTimeZone());
values.put(CalendarContract.Events.EVENT_TIMEZONE,
tz == null ? TimeZone.getDefault().getID() : tz.getID());
values.put(CalendarContract.Events.EVENT_TIMEZONE, tzid);
values.put(CalendarContract.Events.DTSTART, start.getTime());
values.put(CalendarContract.Events.DTEND, end.getTime());
@ -191,7 +194,7 @@ public class CalendarHelper {
" id=" + calId + ":" + eventId +
" uid=" + uid +
" organizer=" + organizer +
" tz=" + (tz == null ? null : tz.getID()) +
" tz=" + tzid +
" start=" + new Date(start.getTime()) +
" end=" + new Date(end.getTime()) +
" rrule=" + rrule +
@ -205,7 +208,7 @@ public class CalendarHelper {
" id=" + calId + ":" + existId +
" uid=" + uid +
" organizer=" + organizer +
" tz=" + (tz == null ? null : tz.getID()) +
" tz=" + tzid +
" start=" + new Date(start.getTime()) +
" end=" + new Date(end.getTime()) +
" rrule=" + rrule +