@Override public PartialTime reduceGranularityTo(Duration granularity) { Partial p = JodaTimeUtils.discardMoreSpecificFields( base, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new CompositePartialTime(this, p, poy.reduceGranularityTo(granularity), dow.reduceGranularityTo(granularity), tod.reduceGranularityTo(granularity)); }
@Override public Duration getGranularity() { StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getGranularity(); } Partial p = this.getJodaTimePartial(); return Duration.getDuration(JodaTimeUtils.getJodaTimePeriod(p)); }
public Range add(Duration d, int flags) { Duration d2 = duration.add(d); Time b2 = begin; Time e2 = end; if ((flags & RANGE_EXPAND_FIX_BEGIN) == 0) { b2 = (end != null) ? end.offset(d2.multiplyBy(-1),0) : null; } else if ((flags & RANGE_EXPAND_FIX_END) == 0) { e2 = (begin != null) ? begin.offset(d2,0) : null; } return new Range(this, b2, e2, d2); }
public Temporal prev() { Duration per = getPeriod(); if (per != null) { if (this instanceof Duration) { return new RelativeTime(new RelativeTime(TemporalOp.THIS, this, DUR_RESOLVE_FROM_AS_REF), TemporalOp.OFFSET, per.multiplyBy(-1)); } else { // return new RelativeTime(new RelativeTime(TemporalOp.THIS, this), // TemporalOp.OFFSET, per.multiplyBy(-1)); return TemporalOp.OFFSET.apply(this, per.multiplyBy(-1)); } } return null; }
@Override public Time add(Duration offset) { //if (getTimeLabel() != null) { if (getStandardTemporalType() != null) { // Time has some meaning, keep as is return new RelativeTime(this, TemporalOp.OFFSET_EXACT, offset); } else { // Some other time, who know what it means // Try to do offset return new InexactTime(this, (Time) TemporalOp.OFFSET_EXACT.apply(base, offset), duration, (Range) TemporalOp.OFFSET_EXACT.apply(range, offset)); } }
@Override public Time add(Duration offset) { // TODO: Check logic // if (getTimeLabel() != null) { if (getStandardTemporalType() != null) { // Time has some meaning, keep as is return new RelativeTime(this, TemporalOp.OFFSET_EXACT, offset); } else return new TimeWithRange(this, range.offset(offset,0)); }
@Override public Duration getDuration() { /* TimeLabel tl = getTimeLabel(); if (tl != null) { return tl.getDuration(); } */ StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getDuration(); } return Duration.getDuration(JodaTimeUtils.getJodaTimePeriod(base)); }
@Override public Temporal resolve(Time refTime, int flags) { Range resolvedOccursIn = (occursIn != null) ? occursIn.resolve(refTime, flags) : null; Temporal resolvedBase = (base != null) ? base.resolve(null, 0) : null; return new PeriodicTemporalSet(this, resolvedBase, this.periodicity, resolvedOccursIn, this.quant, this.freq); }
public PartialTime padMoreSpecificFields(Duration granularity) { Period period = null; if (granularity != null) { period = granularity.getJodaTimePeriod(); } Partial p = JodaTimeUtils.padMoreSpecificFields(base, period); return new PartialTime(this,p); }
public boolean match(TimeExpression te) { if (te != null) { SUTime.Temporal t = te.getTemporal(); if (t != null) { return type.equals(t.getTimexType()); } } return false; } }
@Override public Time intersect(Time t) { if (base instanceof PartialTime && t instanceof PartialTime) { return new OrdinalTime(base.intersect(t), n); } else { return new RelativeTime(t, TemporalOp.INTERSECT, this); } }
@Override public Interval<Time> getInterval() { Range r = getRange(); if (r != null) { return r.getInterval(); } else return null; }
@Override public String toFormattedString(int flags) { if (getTimeLabel() != null) { return getTimeLabel(); } if ((flags & FORMAT_TIMEX3_VALUE) != 0) { flags |= FORMAT_ISO; } return range.toFormattedString(flags); }
public InexactTime(Partial partial) { this.base = new PartialTime(partial); this.range = base.getRange(); this.approx = true; }
@Override public Duration getDuration() { if (duration != null) return duration; if (range != null) return range.getDuration(); else if (base != null) return base.getDuration(); else return null; }
@Override public Partial getJodaTimePartial() { Partial p = null; if (base != null) { p = base.getJodaTimePartial(); } if (p == null && range != null && range.mid() != null) { p = range.mid().getJodaTimePartial(); } return p; }
@Override public Duration divideBy(int m) { Duration min2 = (minDuration != null) ? minDuration.divideBy(m) : null; Duration max2 = (maxDuration != null) ? maxDuration.divideBy(m) : null; return new DurationRange(this, min2, max2); }
@Override public PeriodicTemporalSet setTimeZone(DateTimeZone tz) { return new PeriodicTemporalSet(this, Temporal.setTimeZone(base, tz), periodicity, (Range) Temporal.setTimeZone(occursIn, tz), quant, freq); }