Search in sources :

Example 1 with TimezoneAssignment

use of biweekly.io.TimezoneAssignment in project substitution-schedule-parser by vertretungsplanme.

the class BaseIcalParser method getTimeZoneStart.

private TimeZone getTimeZoneStart(ICalendar ical, VEvent event) {
    if (event.getDateStart() == null) {
        return null;
    }
    TimezoneInfo tzinfo = ical.getTimezoneInfo();
    TimeZone timezone;
    if (tzinfo.isFloating(event.getDateStart())) {
        timezone = TimeZone.getDefault();
    } else {
        TimezoneAssignment dtstartTimezone = tzinfo.getTimezone(event.getDateStart());
        timezone = (dtstartTimezone == null) ? TimeZone.getTimeZone("UTC") : dtstartTimezone.getTimeZone();
    }
    return timezone;
}
Also used : TimezoneInfo(biweekly.io.TimezoneInfo) TimezoneAssignment(biweekly.io.TimezoneAssignment)

Example 2 with TimezoneAssignment

use of biweekly.io.TimezoneAssignment in project common by zenlunatics.

the class EventProvider method writeICS.

// --------------------------------------------------------------------------
@AdminTask
public synchronized void writeICS(Request request) throws IOException {
    ICalendar ical = new ICalendar();
    String string = request.site.getSettings().getString("time zone");
    TimeZone time_zone = TimeZone.getTimeZone(string);
    TimezoneAssignment tza = TimezoneAssignment.download(time_zone, false);
    ical.getTimezoneInfo().setDefaultTimezone(tza);
    ArrayList<Event> events = new ArrayList<Event>();
    addAllEvents(events, request);
    for (Event event : events) {
        VEvent vevent = event.newVEvent(request);
        if (vevent != null)
            ical.addEvent(vevent);
    }
    FilePathStringBuilder fpsb = request.site.getBaseFilePath().append("calendars");
    new File(fpsb.toString()).mkdirs();
    String file_path = fpsb.append(m_name).toString();
    Biweekly.write(ical).go(new File(file_path));
    new File(file_path).renameTo(new File(file_path + ".ics"));
}
Also used : VEvent(biweekly.component.VEvent) TimeZone(java.util.TimeZone) TimezoneAssignment(biweekly.io.TimezoneAssignment) ArrayList(java.util.ArrayList) VEvent(biweekly.component.VEvent) ICalendar(biweekly.ICalendar) FilePathStringBuilder(web.FilePathStringBuilder) File(java.io.File) AdminTask(web.AdminTask)

Aggregations

TimezoneAssignment (biweekly.io.TimezoneAssignment)2 ICalendar (biweekly.ICalendar)1 VEvent (biweekly.component.VEvent)1 TimezoneInfo (biweekly.io.TimezoneInfo)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 TimeZone (java.util.TimeZone)1 AdminTask (web.AdminTask)1 FilePathStringBuilder (web.FilePathStringBuilder)1