use of com.zimbra.common.calendar.ICalTimeZone.SimpleOnset in project zm-mailbox by Zimbra.
the class WindowsTimeZoneInformation method toICal.
public ICalTimeZone toICal() {
SimpleOnset standardOnset = null;
if (mStandardDate != null)
standardOnset = mStandardDate.toSimpleOnset();
SimpleOnset daylightOnset = null;
if (mDaylightDate != null)
daylightOnset = mDaylightDate.toSimpleOnset();
return ICalTimeZone.lookup(mName, mStandardOffsetMillis, standardOnset, mStandardName, mDaylightOffsetMillis, daylightOnset, mDaylightName);
}
use of com.zimbra.common.calendar.ICalTimeZone.SimpleOnset in project zm-mailbox by Zimbra.
the class ToXML method encodeTimeZoneMap.
private static void encodeTimeZoneMap(Element parent, TimeZoneMap tzmap) {
assert (tzmap != null);
for (Iterator<ICalTimeZone> iter = tzmap.tzIterator(); iter.hasNext(); ) {
ICalTimeZone tz = iter.next();
Element e = parent.addElement(MailConstants.E_CAL_TZ);
e.addAttribute(MailConstants.A_ID, tz.getID());
e.addAttribute(MailConstants.A_CAL_TZ_STDOFFSET, tz.getStandardOffset() / 60 / 1000);
e.addAttribute(MailConstants.A_CAL_TZ_STDNAME, tz.getStandardTzname());
if (tz.useDaylightTime()) {
SimpleOnset standard = tz.getStandardOnset();
SimpleOnset daylight = tz.getDaylightOnset();
if (standard != null && daylight != null) {
e.addAttribute(MailConstants.A_CAL_TZ_DAYOFFSET, tz.getDaylightOffset() / 60 / 1000);
e.addAttribute(MailConstants.A_CAL_TZ_DAYNAME, tz.getDaylightTzname());
Element std = e.addElement(MailConstants.E_CAL_TZ_STANDARD);
int standardWeek = standard.getWeek();
if (standardWeek != 0) {
std.addAttribute(MailConstants.A_CAL_TZ_WEEK, standardWeek);
std.addAttribute(MailConstants.A_CAL_TZ_DAYOFWEEK, standard.getDayOfWeek());
} else {
std.addAttribute(MailConstants.A_CAL_TZ_DAYOFMONTH, standard.getDayOfMonth());
}
std.addAttribute(MailConstants.A_CAL_TZ_MONTH, standard.getMonth());
std.addAttribute(MailConstants.A_CAL_TZ_HOUR, standard.getHour());
std.addAttribute(MailConstants.A_CAL_TZ_MINUTE, standard.getMinute());
std.addAttribute(MailConstants.A_CAL_TZ_SECOND, standard.getSecond());
Element day = e.addElement(MailConstants.E_CAL_TZ_DAYLIGHT);
int daylightWeek = daylight.getWeek();
if (daylightWeek != 0) {
day.addAttribute(MailConstants.A_CAL_TZ_WEEK, daylightWeek);
day.addAttribute(MailConstants.A_CAL_TZ_DAYOFWEEK, daylight.getDayOfWeek());
} else {
day.addAttribute(MailConstants.A_CAL_TZ_DAYOFMONTH, daylight.getDayOfMonth());
}
day.addAttribute(MailConstants.A_CAL_TZ_MONTH, daylight.getMonth());
day.addAttribute(MailConstants.A_CAL_TZ_HOUR, daylight.getHour());
day.addAttribute(MailConstants.A_CAL_TZ_MINUTE, daylight.getMinute());
day.addAttribute(MailConstants.A_CAL_TZ_SECOND, daylight.getSecond());
}
}
}
}
use of com.zimbra.common.calendar.ICalTimeZone.SimpleOnset in project zm-mailbox by Zimbra.
the class CalendarUtils method parseTimeZone.
/**
* Parse a <tz> definition, as described in soap-calendar.txt and soap.txt (SearchRequest)
*/
public static ICalTimeZone parseTimeZone(CalTZInfoInterface calTZ) throws ServiceException {
String tzid = calTZ.getId();
if (null == calTZ.getTzStdOffset()) {
throw ServiceException.INVALID_REQUEST("Unknown TZ: \"" + tzid + "\" and no " + MailConstants.A_CAL_TZ_STDOFFSET + " specified", null);
}
int standardOffset = calTZ.getTzStdOffset();
int daylightOffset = Objects.firstNonNull(calTZ.getTzDayOffset(), standardOffset);
// minutes to milliseconds
standardOffset *= 60 * 1000;
daylightOffset *= 60 * 1000;
SimpleOnset standardOnset = null;
SimpleOnset daylightOnset = null;
if (daylightOffset != standardOffset) {
TzOnsetInfo standard = calTZ.getStandardTzOnset();
TzOnsetInfo daylight = calTZ.getDaylightTzOnset();
if (standard == null || daylight == null)
throw ServiceException.INVALID_REQUEST("DST time zone missing standard and/or daylight onset", null);
standardOnset = parseSimpleOnset(standard);
daylightOnset = parseSimpleOnset(daylight);
}
String standardTzname = calTZ.getStandardTZName();
String daylightTzname = calTZ.getDaylightTZName();
return ICalTimeZone.lookup(tzid, standardOffset, standardOnset, standardTzname, daylightOffset, daylightOnset, daylightTzname);
}
use of com.zimbra.common.calendar.ICalTimeZone.SimpleOnset in project zm-mailbox by Zimbra.
the class CalendarUtils method parseTzElement.
/**
* Parse a <tz> definition, as described in soap-calendar.txt and soap.txt (SearchRequest)
*
* @param tzElem
* @return
* @throws ServiceException
*/
public static ICalTimeZone parseTzElement(Element tzElem) throws ServiceException {
String tzid = tzElem.getAttribute(MailConstants.A_ID);
int standardOffset = (int) tzElem.getAttributeLong(MailConstants.A_CAL_TZ_STDOFFSET);
int daylightOffset = (int) tzElem.getAttributeLong(MailConstants.A_CAL_TZ_DAYOFFSET, standardOffset);
// minutes to milliseconds
standardOffset *= 60 * 1000;
daylightOffset *= 60 * 1000;
SimpleOnset standardOnset = null;
SimpleOnset daylightOnset = null;
if (daylightOffset != standardOffset) {
Element standard = tzElem.getOptionalElement(MailConstants.E_CAL_TZ_STANDARD);
Element daylight = tzElem.getOptionalElement(MailConstants.E_CAL_TZ_DAYLIGHT);
if (standard == null || daylight == null)
throw ServiceException.INVALID_REQUEST("DST time zone missing standard and/or daylight onset", null);
standardOnset = parseSimpleOnset(standard);
daylightOnset = parseSimpleOnset(daylight);
}
String standardTzname = tzElem.getAttribute(MailConstants.A_CAL_TZ_STDNAME, null);
String daylightTzname = tzElem.getAttribute(MailConstants.A_CAL_TZ_DAYNAME, null);
return ICalTimeZone.lookup(tzid, standardOffset, standardOnset, standardTzname, daylightOffset, daylightOnset, daylightTzname);
}
Aggregations