/** * Returns the mandatory dtstart property. * * @return the DTSTART property or null if not specified */ public final DtStart getStartDate() { return getProperty(Property.DTSTART); }
DtStart dtStart = (DtStart) getRequiredProperty(Property.DTSTART); initialOnset = applyOffsetFrom(calculateOnset(dtStart.getDate())); } catch (ParseException | ConstraintViolationException e) { Logger log = LoggerFactory.getLogger(Observance.class); return getCachedOnset(date); initialOnsetUTC = calculateOnset(((DtStart) getProperty(Property.DTSTART)).getDate()); } catch (ParseException e) { Logger log = LoggerFactory.getLogger(Observance.class); final List<RDate> rdates = getProperties(Property.RDATE); for (RDate rdate : rdates) { for (final Date rdateDate : rdate.getDates()) { try { final DateTime rdateOnset = applyOffsetFrom(calculateOnset(rdateDate)); if (!rdateOnset.after(date) && rdateOnset.after(onset)) { onset = rdateOnset; final List<RRule> rrules = getProperties(Property.RRULE); for (RRule rrule : rrules) { onsetLimit, Value.DATE_TIME); for (final Date recurDate : recurrenceDates) { final DateTime rruleOnset = applyOffsetFrom((DateTime) recurDate); if (!rruleOnset.after(date) && rruleOnset.after(onset)) { onset = rruleOnset;
/** * {@inheritDoc} */ public final void validate(final boolean recurse) throws ValidationException { // From "4.8.3.3 Time Zone Offset From": // Conformance: This property MUST be specified in a "VTIMEZONE" // calendar component. PropertyValidator.getInstance().assertOne(Property.TZOFFSETFROM, getProperties()); // From "4.8.3.4 Time Zone Offset To": // Conformance: This property MUST be specified in a "VTIMEZONE" // calendar component. PropertyValidator.getInstance().assertOne(Property.TZOFFSETTO, getProperties()); /* * ; the following are each REQUIRED, ; but MUST NOT occur more than once dtstart / tzoffsetto / tzoffsetfrom / */ PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties()); /* * ; the following are optional, ; and MAY occur more than once comment / rdate / rrule / tzname / x-prop */ if (recurse) { validateProperties(); } }
/** * {@inheritDoc} */ public void validate(VTimeZone target) throws ValidationException { for (final Observance observance : target.getObservances()) { Arrays.asList(DTSTART, TZOFFSETFROM, TZOFFSETTO).forEach( property -> PropertyValidator.getInstance().assertOne(property, observance.getProperties())); PropertyValidator.getInstance().assertOneOrLess(TZNAME, observance.getProperties()); } } }
Date latestOnset = null; for (Observance seasonalTime : seasonalTimes) { Date onset = seasonalTime.getLatestOnset(now); if (onset == null) { continue; final TzOffsetTo offsetTo = latestSeasonalTime.getProperty(Property.TZOFFSETTO); if (offsetTo != null) { return (int) (offsetTo.getOffset().getTotalSeconds() * 1000L);
/** * Returns the latest applicable timezone observance for the specified date. * @param date the latest possible date for a timezone observance onset * @return the latest applicable timezone observance for the specified date or null if there are no applicable * observances */ public final Observance getApplicableObservance(final Date date) { Observance latestObservance = null; Date latestOnset = null; for (final Observance observance : getObservances()) { final Date onset = observance.getLatestOnset(date); if (latestOnset == null || (onset != null && onset.after(latestOnset))) { latestOnset = onset; latestObservance = observance; } } return latestObservance; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - getOffsetFrom().getOffset().getOffset()); return withOffset; } }
observance.validate(recurse);
DtStart dtStart = (DtStart) getRequiredProperty(Property.DTSTART); initialOnset = applyOffsetFrom(calculateOnset(dtStart.getDate())); } catch (ParseException | ConstraintViolationException e) { Logger log = LoggerFactory.getLogger(Observance.class); return getCachedOnset(date); initialOnsetUTC = calculateOnset(((DtStart) getProperty(Property.DTSTART)).getDate()); } catch (ParseException e) { Logger log = LoggerFactory.getLogger(Observance.class); final List<RDate> rdates = getProperties(Property.RDATE); for (RDate rdate : rdates) { for (final Date rdateDate : rdate.getDates()) { try { final DateTime rdateOnset = applyOffsetFrom(calculateOnset(rdateDate)); if (!rdateOnset.after(date) && rdateOnset.after(onset)) { onset = rdateOnset; final List<RRule> rrules = getProperties(Property.RRULE); for (RRule rrule : rrules) { onsetLimit, Value.DATE_TIME); for (final Date recurDate : recurrenceDates) { final DateTime rruleOnset = applyOffsetFrom((DateTime) recurDate); if (!rruleOnset.after(date) && rruleOnset.after(onset)) { onset = rruleOnset;
/** * {@inheritDoc} */ public final void validate(final boolean recurse) throws ValidationException { // From "4.8.3.3 Time Zone Offset From": // Conformance: This property MUST be specified in a "VTIMEZONE" // calendar component. PropertyValidator.getInstance().assertOne(Property.TZOFFSETFROM, getProperties()); // From "4.8.3.4 Time Zone Offset To": // Conformance: This property MUST be specified in a "VTIMEZONE" // calendar component. PropertyValidator.getInstance().assertOne(Property.TZOFFSETTO, getProperties()); /* * ; the following are each REQUIRED, ; but MUST NOT occur more than once dtstart / tzoffsetto / tzoffsetfrom / */ PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties()); /* * ; the following are optional, ; and MAY occur more than once comment / rdate / rrule / tzname / x-prop */ if (recurse) { validateProperties(); } }
/** * {@inheritDoc} */ public void validate(VTimeZone target) throws ValidationException { for (final Observance observance : target.getObservances()) { Arrays.asList(DTSTART, TZOFFSETFROM, TZOFFSETTO).forEach( property -> PropertyValidator.getInstance().assertOne(property, observance.getProperties())); PropertyValidator.getInstance().assertOneOrLess(TZNAME, observance.getProperties()); } } }
Date latestOnset = null; for (Observance seasonalTime : seasonalTimes) { Date onset = seasonalTime.getLatestOnset(now); if (onset == null) { continue; final TzOffsetTo offsetTo = (TzOffsetTo) latestSeasonalTime.getProperty(Property.TZOFFSETTO); if (offsetTo != null) { return (int) offsetTo.getOffset().getOffset();
/** * Returns the latest applicable timezone observance for the specified date. * @param date the latest possible date for a timezone observance onset * @return the latest applicable timezone observance for the specified date or null if there are no applicable * observances */ public final Observance getApplicableObservance(final Date date) { Observance latestObservance = null; Date latestOnset = null; for (final Observance observance : getObservances()) { final Date onset = observance.getLatestOnset(date); if (latestOnset == null || (onset != null && onset.after(latestOnset))) { latestOnset = onset; latestObservance = observance; } } return latestObservance; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - (getOffsetFrom().getOffset().getTotalSeconds() * 1000L)); return withOffset; } }
observance.validate(recurse);
DtStart dtStart = (DtStart) getRequiredProperty(Property.DTSTART); initialOnset = applyOffsetFrom(calculateOnset(dtStart.getDate())); } catch (ParseException e) { Logger log = LoggerFactory.getLogger(Observance.class); return getCachedOnset(date); initialOnsetUTC = calculateOnset(((DtStart) getProperty(Property.DTSTART)).getDate()); } catch (ParseException e) { Logger log = LoggerFactory.getLogger(Observance.class); final List<RDate> rdates = getProperties(Property.RDATE); for (RDate rdate : rdates) { for (final Date rdateDate : rdate.getDates()) { try { final DateTime rdateOnset = applyOffsetFrom(calculateOnset(rdateDate)); if (!rdateOnset.after(date) && rdateOnset.after(onset)) { onset = rdateOnset; final List<RRule> rrules = getProperties(Property.RRULE); for (RRule rrule : rrules) { onsetLimit, Value.DATE_TIME); for (final Date recurDate : recurrenceDates) { final DateTime rruleOnset = applyOffsetFrom((DateTime) recurDate); if (!rruleOnset.after(date) && rruleOnset.after(onset)) { onset = rruleOnset;
/** * {@inheritDoc} */ public final void validate(final boolean recurse) throws ValidationException { // From "4.8.3.3 Time Zone Offset From": // Conformance: This property MUST be specified in a "VTIMEZONE" // calendar component. PropertyValidator.getInstance().assertOne(Property.TZOFFSETFROM, getProperties()); // From "4.8.3.4 Time Zone Offset To": // Conformance: This property MUST be specified in a "VTIMEZONE" // calendar component. PropertyValidator.getInstance().assertOne(Property.TZOFFSETTO, getProperties()); /* * ; the following are each REQUIRED, ; but MUST NOT occur more than once dtstart / tzoffsetto / tzoffsetfrom / */ PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties()); /* * ; the following are optional, ; and MAY occur more than once comment / rdate / rrule / tzname / x-prop */ if (recurse) { validateProperties(); } }
/** * {@inheritDoc} */ public void validate(VTimeZone target) throws ValidationException { for (final Observance observance : target.getObservances()) { PropertyValidator.getInstance().assertOne(Property.DTSTART, observance.getProperties()); PropertyValidator.getInstance().assertOne(Property.TZOFFSETFROM, observance.getProperties()); PropertyValidator.getInstance().assertOne(Property.TZOFFSETTO, observance.getProperties()); PropertyValidator.getInstance().assertOneOrLess(Property.TZNAME, observance.getProperties()); } } }