use of com.zimbra.soap.type.TzOnsetInfo 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);
}
Aggregations