@Override public PlainTimestamp addTo(PlainTimestamp tsp, long amount) { PlainDate date = dateRule.addTo(tsp.toDate(), amount); return PlainTimestamp.of(date, tsp.toTime()); } @Override
/** * <p>Does this rule match given timestamp such that any rule interval contains it? </p> * * <p>Example: If this rule describes shop opening times then this method yields the answer to the * question if the shop is open at given timestamp. </p> * * @param timestamp the timestamp to be checked * @return {@code true} if given timestamp fits to this rule else {@code false} * @since 4.20 */ /*[deutsch] * <p>Prüft, ob irgendein Zeitintervall dieser Regel den angegebenen Zeitstempel enthält. </p> * * <p>Beispiel: Wenn diese Regel Ladenöffnungszeiten beschreibt, dann liefert diese Methode die * Antwort auf die Frage, ob der Laden zur angegebenen Zeit offen ist. </p> * * @param timestamp the timestamp to be checked * @return {@code true} if given timestamp fits to this rule else {@code false} * @since 4.20 */ default boolean matches(PlainTimestamp timestamp) { for (ChronoInterval<PlainTime> interval : this.getPartition(timestamp.toDate())) { if (interval.contains(timestamp.toTime())) { return true; } } return false; }
@Override public CalendarWeek createFrom( TimeSource<?> clock, AttributeQuery attributes ) { Timezone zone; if (attributes.contains(Attributes.TIMEZONE_ID)) { zone = Timezone.of(attributes.get(Attributes.TIMEZONE_ID)); } else if (attributes.get(Attributes.LENIENCY, Leniency.SMART).isLax()) { zone = Timezone.ofSystem(); } else { return null; } PlainDate date = Moment.from(clock.currentTime()).toZonalTimestamp(zone.getID()).toDate(); return CalendarWeek.of(date.getInt(YEAR_OF_WEEKDATE), date.getInt(WEEK_OF_YEAR)); }
@Override public CalendarQuarter createFrom( TimeSource<?> clock, AttributeQuery attributes ) { Timezone zone; if (attributes.contains(Attributes.TIMEZONE_ID)) { zone = Timezone.of(attributes.get(Attributes.TIMEZONE_ID)); } else if (attributes.get(Attributes.LENIENCY, Leniency.SMART).isLax()) { zone = Timezone.ofSystem(); } else { return null; } PlainDate date = Moment.from(clock.currentTime()).toZonalTimestamp(zone.getID()).toDate(); return CalendarQuarter.of(date.getYear(), date.get(QUARTER_OF_YEAR)); }
@Override public CalendarMonth createFrom( TimeSource<?> clock, AttributeQuery attributes ) { Timezone zone; if (attributes.contains(Attributes.TIMEZONE_ID)) { zone = Timezone.of(attributes.get(Attributes.TIMEZONE_ID)); } else if (attributes.get(Attributes.LENIENCY, Leniency.SMART).isLax()) { zone = Timezone.ofSystem(); } else { return null; } PlainDate date = Moment.from(clock.currentTime()).toZonalTimestamp(zone.getID()).toDate(); return CalendarMonth.of(date.getYear(), Month.valueOf(date.getMonth())); }
PlainDate refDate = refTime.toZonalTimestamp(tzid).toDate(); Duration<CalendarUnit> duration;