use of com.zimbra.common.calendar.ParsedDateTime in project zm-mailbox by Zimbra.
the class Recurrence method getReferencedTZIDs.
// Get the set of TZIDs referenced in a recurrence. RDATE and EXDATE can use TZID parameter.
public static Set<String> getReferencedTZIDs(IRecurrence recur) {
Set<String> tzids = new HashSet<String>();
// RDATE
for (Iterator iter = recur.addRulesIterator(); iter != null && iter.hasNext(); ) {
IRecurrence cur = (IRecurrence) iter.next();
if (cur.getType() == Recurrence.TYPE_SINGLE_DATES) {
Recurrence.SingleDates sd = (Recurrence.SingleDates) cur;
RdateExdate rdate = sd.getRdateExdate();
ICalTimeZone tz = rdate.getTimeZone();
if (tz != null)
tzids.add(tz.getID());
}
}
// EXDATE
for (Iterator iter = recur.subRulesIterator(); iter != null && iter.hasNext(); ) {
IRecurrence cur = (IRecurrence) iter.next();
if (cur.getType() == Recurrence.TYPE_SINGLE_DATES) {
Recurrence.SingleDates sd = (Recurrence.SingleDates) cur;
RdateExdate exdate = sd.getRdateExdate();
ICalTimeZone tz = exdate.getTimeZone();
if (tz != null)
tzids.add(tz.getID());
}
}
ParsedDateTime recurStart = recur.getStartTime();
if (recurStart != null) {
ICalTimeZone tz = recurStart.getTimeZone();
if (tz != null)
tzids.add(tz.getID());
}
return tzids;
}
use of com.zimbra.common.calendar.ParsedDateTime in project zm-mailbox by Zimbra.
the class InviteChanges method diffInvites.
private void diffInvites(Invite inv1, Invite inv2) {
// Subject
if (!StringUtil.equal(inv1.getName(), inv2.getName()))
mChanges |= SUBJECT;
// LOCATION
if (!StringUtil.equal(inv1.getLocation(), inv2.getLocation()))
mChanges |= LOCATION;
// DTSTART
boolean dtStartChanged;
ParsedDateTime dtStart1 = inv1.getStartTime();
ParsedDateTime dtStart2 = inv2.getStartTime();
if (dtStart1 == null || dtStart2 == null)
dtStartChanged = dtStart1 != dtStart2;
else
dtStartChanged = !StringUtil.equal(dtStart1.getDateTimePartString(false), dtStart2.getDateTimePartString(false));
if (dtStartChanged) {
mChanges |= TIME;
} else {
// DTEND
boolean dtEndChanged;
ParsedDateTime dtEnd1 = inv1.getEndTime();
ParsedDateTime dtEnd2 = inv2.getEndTime();
if (dtEnd1 == null || dtEnd2 == null)
dtEndChanged = dtEnd1 != dtEnd2;
else
dtEndChanged = !StringUtil.equal(dtEnd1.getDateTimePartString(false), dtEnd2.getDateTimePartString(false));
if (dtEndChanged) {
mChanges |= TIME;
} else {
boolean durationChanged;
ParsedDuration dur1 = inv1.getDuration();
ParsedDuration dur2 = inv2.getDuration();
if (dur1 == null || dur2 == null)
durationChanged = dur1 != dur2;
else
durationChanged = !dur1.equals(dur2);
if (durationChanged)
mChanges |= TIME;
}
}
// Recurrence
boolean recurChanged;
IRecurrence recur1 = inv1.getRecurrence();
IRecurrence recur2 = inv2.getRecurrence();
if (recur1 == null || recur2 == null) {
recurChanged = recur1 != recur2;
} else {
recurChanged = !Recurrence.sameSeriesRules(recur1, recur2);
}
if (recurChanged)
mChanges |= RECURRENCE;
}
use of com.zimbra.common.calendar.ParsedDateTime in project zm-mailbox by Zimbra.
the class Period method parse.
public static Period parse(String value, ICalTimeZone tz, TimeZoneMap tzmap) throws ServiceException, ParseException {
String[] parsed = value.split("\\/", 2);
if (parsed.length != 2 || parsed[0].length() == 0 || parsed[1].length() == 1)
throw ServiceException.INVALID_REQUEST("Invalid PERIOD value \"" + value + "\"", null);
ParsedDateTime startTime;
startTime = ParsedDateTime.parse(parsed[0], tzmap, tz, tzmap.getLocalTimeZone());
char ch = parsed[1].charAt(0);
if (ch == 'P' || ch == '+' || ch == '-') {
ParsedDuration duration = ParsedDuration.parse(parsed[1]);
return new Period(startTime, duration);
} else {
ParsedDateTime endTime = ParsedDateTime.parse(parsed[1], tzmap, tz, tzmap.getLocalTimeZone());
return new Period(startTime, endTime);
}
}
use of com.zimbra.common.calendar.ParsedDateTime in project zm-mailbox by Zimbra.
the class RdateExdate method getDatesCSV.
private String getDatesCSV() {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object value : mValues) {
if (first)
first = false;
else
sb.append(",");
if (value instanceof ParsedDateTime) {
ParsedDateTime t = (ParsedDateTime) value;
sb.append(t.getDateTimePartString(false));
} else if (value instanceof Period)
sb.append(value.toString());
}
return sb.toString();
}
use of com.zimbra.common.calendar.ParsedDateTime in project zm-mailbox by Zimbra.
the class RdateExdate method toXml.
public Element toXml(Element parent) {
if (isRDATE() && !DebugConfig.enableRdate) {
return null;
}
Element dateElem = parent.addElement(MailConstants.E_CAL_DATES);
if (mTimeZone != null)
dateElem.addAttribute(MailConstants.A_CAL_TIMEZONE, mTimeZone.getID());
for (Object val : mValues) {
Element dtvalElem = dateElem.addElement(MailConstants.E_CAL_DATE_VAL);
if (val instanceof ParsedDateTime) {
ParsedDateTime dt = (ParsedDateTime) val;
Element startElem = dtvalElem.addElement(MailConstants.E_CAL_START_TIME);
startElem.addAttribute(MailConstants.A_CAL_DATETIME, dt.getDateTimePartString(false));
} else if (val instanceof Period) {
Period p = (Period) val;
Element startElem = dtvalElem.addElement(MailConstants.E_CAL_START_TIME);
startElem.addAttribute(MailConstants.A_CAL_DATETIME, p.getStart().getDateTimePartString(false));
if (p.hasEnd()) {
Element endElem = dtvalElem.addElement(MailConstants.E_CAL_END_TIME);
endElem.addAttribute(MailConstants.A_CAL_DATETIME, p.getEnd().getDateTimePartString(false));
} else {
p.getDuration().toXml(dtvalElem);
}
}
}
return dateElem;
}
Aggregations