use of net.fortuna.ical4j.model.DateList in project OpenOLAT by OpenOLAT.
the class CalendarUtils method getRecurrenceExcludeDates.
/**
* Create list with excluded dates based on the exclusion rule.
* @param recurrenceExc
* @return list with excluded dates
*/
public static List<Date> getRecurrenceExcludeDates(String recurrenceExc) {
List<Date> recurExcDates = new ArrayList<>();
if (recurrenceExc != null && !recurrenceExc.equals("")) {
try {
net.fortuna.ical4j.model.ParameterList pl = new net.fortuna.ical4j.model.ParameterList();
ExDate exdate = new ExDate(pl, recurrenceExc);
DateList dl = exdate.getDates();
for (Object date : dl) {
Date excDate = (Date) date;
recurExcDates.add(excDate);
}
} catch (ParseException e) {
log.error("cannot restore recurrence exceptions", e);
}
}
return recurExcDates;
}
use of net.fortuna.ical4j.model.DateList in project bw-calendar-engine by Bedework.
the class IcalUtil method makeDateTimes.
/**
* @param val
* @return Collection
* @throws Throwable
*/
public static Collection<BwDateTime> makeDateTimes(final DateListProperty val) throws Throwable {
DateList dl = val.getDates();
TreeSet<BwDateTime> ts = new TreeSet<BwDateTime>();
Parameter par = getParameter(val, "VALUE");
boolean isDateType = (par != null) && (par.equals(Value.DATE));
String tzidval = null;
Parameter tzid = getParameter(val, "TZID");
if (tzid != null) {
tzidval = tzid.getValue();
}
Iterator it = dl.iterator();
while (it.hasNext()) {
Date dt = (Date) it.next();
ts.add(BwDateTime.makeBwDateTime(isDateType, dt.toString(), tzidval));
}
return ts;
}
use of net.fortuna.ical4j.model.DateList in project bw-calendar-engine by Bedework.
the class RecurUtil method getLastDate.
/* Return the highest possible start date from this recurrence or null
* if no count or until date specified
*/
private static Date getLastDate(final Recur r, Date start, final Date maxRangeEnd) {
Date seed = start;
Date until = r.getUntil();
if (until != null) {
return until;
}
int count = r.getCount();
if (count < 1) {
return null;
}
Dur days100 = new Dur(100, 0, 0, 0);
int counted = 0;
while ((counted < count) && (start.before(maxRangeEnd))) {
Date end = new DateTime(days100.getTime(start));
DateList dl = r.getDates(seed, start, end, Value.DATE_TIME);
int sz = dl.size();
counted += sz;
if (sz != 0) {
until = (Date) dl.get(sz - 1);
}
start = end;
}
return until;
}
use of net.fortuna.ical4j.model.DateList in project bw-calendar-engine by Bedework.
the class VEventUtil method makeDlp.
private static void makeDlp(final BwEvent val, final boolean exdt, final Collection<BwDateTime> dts, final PropertyList pl) throws Throwable {
if ((dts == null) || (dts.isEmpty())) {
return;
}
TimeZone tz = null;
if (!val.getForceUTC()) {
BwDateTime dtstart = val.getDtstart();
if ((dtstart != null) && !dtstart.isUTC()) {
DtStart ds = dtstart.makeDtStart();
tz = ds.getTimeZone();
}
}
/* Generate as one date per property - matches up to other vendors better */
for (BwDateTime dt : dts) {
DateList dl = null;
/* Always use the UTC values */
boolean dateType = false;
if (dt.getDateType()) {
dl = new DateList(Value.DATE);
dl.setUtc(true);
dateType = true;
dl.add(new Date(dt.getDtval()));
} else {
dl = new DateList(Value.DATE_TIME);
if (tz == null) {
dl.setUtc(true);
DateTime dtm = new DateTime(dt.getDate());
dtm.setUtc(true);
dl.add(dtm);
} else {
dl.setTimeZone(tz);
DateTime dtm = new DateTime(dt.getDate());
dtm.setTimeZone(tz);
dl.add(dtm);
}
}
DateListProperty dlp;
if (exdt) {
dlp = new ExDate(dl);
} else {
dlp = new RDate(dl);
}
if (tz != null) {
dlp.setTimeZone(tz);
}
if (dateType) {
dlp.getParameters().add(Value.DATE);
}
pl.add(dlp);
}
}
use of net.fortuna.ical4j.model.DateList in project openolat by klemens.
the class CalendarUtils method getRecurrenceExcludeRule.
/**
* Create exclusion rule based on list with dates.
* @param dates
* @return string with exclude rule
*/
public static String getRecurrenceExcludeRule(List<Date> dates) {
if (dates != null && dates.size() > 0) {
DateList dl = new DateList();
for (Date date : dates) {
net.fortuna.ical4j.model.Date dd = CalendarUtils.createDate(date);
dl.add(dd);
}
ExDate exdate = new ExDate(dl);
return exdate.getValue();
}
return null;
}
Aggregations