@Override public PlainTimestamp plusPeriod( PlainTimestamp timepoint, String period, ParseLog plog, AttributeQuery attributes ) { try { return timepoint.plus(Duration.parsePeriod(period)); } catch (ParseException ex) { return null; } }
private PlainTimestamp handleSameTimes(PlainTimestamp entity) { switch (this.mode) { case ElementOperator.OP_NAV_NEXT: return entity.plus(1, CalendarUnit.DAYS); case ElementOperator.OP_NAV_PREVIOUS: return entity.minus(1, CalendarUnit.DAYS); case ElementOperator.OP_NAV_NEXT_OR_SAME: case ElementOperator.OP_NAV_PREVIOUS_OR_SAME: return entity; default: throw new AssertionError("Unknown: " + this.mode); } }
private PlainTimestamp handleEarlier(PlainTimestamp entity) { switch (this.mode) { case ElementOperator.OP_NAV_NEXT: case ElementOperator.OP_NAV_NEXT_OR_SAME: return entity.plus(1, CalendarUnit.DAYS).with(this.value); case ElementOperator.OP_NAV_PREVIOUS: case ElementOperator.OP_NAV_PREVIOUS_OR_SAME: return entity.with(this.value); default: throw new AssertionError("Unknown: " + this.mode); } }
) { return this.plus(Math.negateExact(amount), unit);
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('R'); int c = this.getCount(); if (c != INFINITE) { sb.append(this.getCount()); } sb.append('/'); switch (this.getType()) { case TYPE_START_DURATION: sb.append(this.ref); sb.append('/'); sb.append(this.duration); break; case TYPE_DURATION_END: sb.append(this.duration); sb.append('/'); sb.append(this.ref); break; case TYPE_START_END: sb.append(this.ref); sb.append('/'); sb.append(this.ref.plus(this.duration)); break; } return sb.toString(); }
) { return this.plus(Math.negateExact(amount), unit);
public Duration<IsoUnit> normalize(TimeSpan<? extends IsoUnit> timespan) { return this.until(this.plus(timespan), STD_METRIC);
sb.append(this.getOffsetAsString()); sb.append('/'); sb.append(this.ref.plus(this.duration)); sb.append(this.getOffsetAsString()); break;
@Override public Moment plusPeriod( Moment timepoint, String period, ParseLog plog, AttributeQuery attributes ) { Timezone tz = getTimezone(plog.getRawValues(), attributes); PlainTimestamp tsp = timepoint.toZonalTimestamp(tz.getID()); try { return tsp.plus(Duration.parsePeriod(period)).in(tz); } catch (ParseException ex) { return null; } }
Moment unix = Moment.from(refClock.currentTime()); PlainTimestamp start = unix.toZonalTimestamp(ZonalOffset.UTC); PlainTimestamp end = start.plus(amount, unit); IsoUnit[] units = (weekToDays ? TSP_UNITS : STD_UNITS); Duration<?> part = Duration.in(units).between(start, end);
@Override public PlainTimestamp withValue( PlainTimestamp context, int value, boolean lenient ) { if (value == this.getInt(context)) { return context; } else if (lenient) { // nur auf numerischen Elementen definiert IsoUnit unit = ENGINE.getBaseUnit(this.element); long amount = MathUtils.safeSubtract((long) value, this.getInt(context)); return context.plus(amount, unit); } else if (this.element.isDateElement()) { PlainDate date = context.date.with(this.element, value); return PlainTimestamp.of(date, context.time); } else if (this.element.isTimeElement()) { int min = this.element.getDefaultMinimum().intValue(); int max = this.element.getDefaultMaximum().intValue(); if ((min > value) || (max < value)) { throw new IllegalArgumentException("Out of range: " + value); } PlainTime time = context.time.with(this.element, value); return PlainTimestamp.of(context.date, time); } throw new ChronoException( "Missing rule for: " + this.element.name()); }
@Override protected TimestampInterval nextInterval() { PlainTimestamp next; Boundary<PlainTimestamp> s; Boundary<PlainTimestamp> e; if (RecurrentTimestampIntervals.this.isBackwards()) { next = this.current.minus(RecurrentTimestampIntervals.this.duration); s = Boundary.ofClosed(next); e = Boundary.ofOpen(this.current); } else { next = this.current.plus(RecurrentTimestampIntervals.this.duration); s = Boundary.ofClosed(this.current); e = Boundary.ofOpen(next); } this.current = next; return TimestampIntervalFactory.INSTANCE.between(s, e); } };
long newValue = this.toNumber(value); long amount = MathUtils.safeSubtract(newValue, oldValue); return context.plus(amount, unit); } else if (this.element.isDateElement()) { PlainDate date = context.date.with(this.element, value);
tsp = tsp.minus(1, CalendarUnit.DAYS); } else if (comp < 0) { // happens if sunrise is the start of day tsp = tsp.plus(1, CalendarUnit.DAYS);
tsp = tsp.minus(1, CalendarUnit.DAYS); } else if (comp < 0) { // happens if sunrise is the start of day tsp = tsp.plus(1, CalendarUnit.DAYS);
@Override protected MomentInterval nextInterval() { PlainTimestamp next; Boundary<Moment> s; Boundary<Moment> e; if (RecurrentMomentIntervals.this.isBackwards()) { next = this.current.minus(RecurrentMomentIntervals.this.duration); s = Boundary.ofClosed(next.at(offset)); e = Boundary.ofOpen(this.current.at(offset)); } else { next = this.current.plus(RecurrentMomentIntervals.this.duration); s = Boundary.ofClosed(this.current.at(offset)); e = Boundary.ofOpen(next.at(offset)); } this.current = next; return MomentIntervalFactory.INSTANCE.between(s, e); } };