@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Duration && arg2 instanceof Duration) { return ((Duration) arg1).add((Duration) arg2); } else if (arg1 instanceof Time && arg2 instanceof Duration) { return ((Time) arg1).add((Duration) arg2); } else if (arg1 instanceof Range && arg2 instanceof Duration) { return ((Range) arg1).add((Duration) arg2); } else { throw new UnsupportedOperationException("PLUS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
if (resolvedGranularity != null && refGranularity != null && resolvedGranularity.compareTo(refGranularity) >= 0) { if ((flags & RESOLVE_TO_PAST) != 0) { if (resolved.compareTo(ref) > 0) {
@Override public Temporal resolve(Time t, int flags) { if (t == null) return this; // No resolving to be done? if (base instanceof PartialTime) { PartialTime pt = (PartialTime) base.resolve(t,flags); List<Temporal> list = pt.toList(); if (list != null && list.size() >= n) { return list.get(n-1); } } else if (base instanceof Duration) { Duration d = ((Duration) base).multiplyBy(n-1); Time temp = t.getRange().begin(); return temp.offset(d,0).reduceGranularityTo(d.getDuration()); } return this; }
DateTimeFieldType[] dtFieldTypes = getDateTimeFields(); Time t = null; if (dtFieldTypes != null) { likelyRange = new Range(minTime, refTime, this); } else { Duration halfDuration = this.divideBy(2); likelyRange = new Range(refTime.subtract(halfDuration), refTime.add(halfDuration), this); return new TimeWithRange(likelyRange); Range r = new Range(minTime, maxTime, this.multiplyBy(2)); return new InexactTime(new TimeWithRange(likelyRange), this, r);
DateTimeFieldType[] dtFieldTypes = getDateTimeFields(); if (dtFieldTypes != null) { Time t = null; likelyRange = new Range(minTime, refTime, this); } else { Duration halfDuration = this.divideBy(2); likelyRange = new Range(refTime.subtract(halfDuration), refTime.add(halfDuration), this);
DateTimeFieldType[] dtFieldTypes = getDateTimeFields(); if (dtFieldTypes != null) { Time t = null; likelyRange = new Range(minTime, refTime, this); } else { Duration halfDuration = this.divideBy(2); likelyRange = new Range(refTime.subtract(halfDuration), refTime.add(halfDuration), this); return new TimeWithRange(likelyRange); Range r = new Range(minTime, maxTime, this.multiplyBy(2)); return new InexactTime(new TimeWithRange(likelyRange), this, r);
public static Pair<PartialTime, PartialTime> getCompatible(PartialTime t1, PartialTime t2) { // Incompatible timezones if (t1.dateTimeZone != null && t2.dateTimeZone != null && !t1.dateTimeZone.equals(t2.dateTimeZone)) return null; if (t1.isCompatible(t2)) return Pair.makePair(t1,t2); if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity == null) { if (t1.uncertaintyGranularity.compareTo(t2.getDuration()) > 0) { // Drop the uncertain fields from t1 Duration d = t1.uncertaintyGranularity; PartialTime t1b = t1.reduceGranularityTo(d); if (t1b.isCompatible(t2)) return Pair.makePair(t1b,t2); } } else if (t1.uncertaintyGranularity == null && t2.uncertaintyGranularity != null) { if (t2.uncertaintyGranularity.compareTo(t1.getDuration()) > 0) { // Drop the uncertain fields from t2 Duration d = t2.uncertaintyGranularity; PartialTime t2b = t2.reduceGranularityTo(d); if (t1.isCompatible(t2b)) return Pair.makePair(t1,t2b); } } else if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity != null) { Duration d1 = Duration.max(t1.uncertaintyGranularity, t2.getDuration()); Duration d2 = Duration.max(t2.uncertaintyGranularity, t1.getDuration()); PartialTime t1b = t1.reduceGranularityTo(d1); PartialTime t2b = t2.reduceGranularityTo(d2); if (t1b.isCompatible(t2b)) return Pair.makePair(t1b,t2b); } return null; }
public int compareTo(Duration d) { org.joda.time.Duration d1 = getJodaTimeDuration(); org.joda.time.Duration d2 = d.getJodaTimeDuration(); if (d1 == null && d2 == null) { return 0; } else if (d1 == null) { return 1; } else if (d2 == null) { return -1; } int cmp = d1.compareTo(d2); if (cmp == 0) { if (d.isApprox() && !this.isApprox()) { // Put exact in front of approx return -1; } else if (!d.isApprox() && this.isApprox()) { return 1; } else { return 0; } } else { return cmp; } }
@Override public int compareTo(Duration d) { org.joda.time.Duration d1 = getJodaTimeDuration(); org.joda.time.Duration d2 = d.getJodaTimeDuration(); if (d1 == null && d2 == null) { return 0; } else if (d1 == null) { return 1; } else if (d2 == null) { return -1; } int cmp = d1.compareTo(d2); if (cmp == 0) { if (d.isApprox() && !this.isApprox()) { // Put exact in front of approx return -1; } else if (!d.isApprox() && this.isApprox()) { return 1; } else { return 0; } } else { return cmp; } }
public Duration getDuration() { /* TimeLabel tl = getTimeLabel(); if (tl != null) { return tl.getDuration(); } */ StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getDuration(); } Duration bd = (base != null) ? Duration.getDuration(JodaTimeUtils.getJodaTimePeriod(base)) : null; if (tod != null) { Duration d = tod.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } if (dow != null) { Duration d = dow.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } if (poy != null) { Duration d = poy.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } return bd; }
@Override public Duration getDuration() { /* TimeLabel tl = getTimeLabel(); if (tl != null) { return tl.getDuration(); } */ StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getDuration(); } Duration bd = (base != null) ? Duration.getDuration(JodaTimeUtils.getJodaTimePeriod(base)) : null; if (tod != null) { Duration d = tod.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } if (dow != null) { Duration d = dow.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } if (poy != null) { Duration d = poy.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } return bd; }
public int compareTo(Duration d) { org.joda.time.Duration d1 = getJodaTimeDuration(); org.joda.time.Duration d2 = d.getJodaTimeDuration(); if (d1 == null && d2 == null) { return 0; } else if (d1 == null) { return 1; } else if (d2 == null) { return -1; } int cmp = d1.compareTo(d2); if (cmp == 0) { if (d.isApprox() && !this.isApprox()) { // Put exact in front of approx return -1; } else if (!d.isApprox() && this.isApprox()) { return 1; } else { return 0; } } else { return cmp; } }
public Duration getDuration() { TimeLabel tl = getTimeLabel(); if (tl != null) { return tl.getDuration(); } TimeLabelType tlt = getTimeLabelType(); if (tlt != null) { return tlt.getDuration(); } Duration bd = (base != null) ? Duration.getDuration(JodaTimeUtils.getJodaTimePeriod(base)) : null; if (tod != null) { Duration d = tod.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } if (dow != null) { Duration d = dow.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } if (poy != null) { Duration d = poy.getDuration(); return (bd.compareTo(d) < 0) ? bd : d; } return bd; }
public String toFormattedString(int flags) { if (getTimeLabel() != null) { if (getTimeLabel().isoString != null) { return getTimeLabel().isoString; } } Period p = getJodaTimePeriod(); String s = (p != null) ? p.toString() : "PXX"; if ((flags & (FORMAT_ISO | FORMAT_TIMEX3_VALUE)) == 0) { String m = getMod(); if (m != null) { try { TimexMod tm = TimexMod.valueOf(m); if (tm.getSymbol() != null) { s = tm.getSymbol() + s; } } catch (Exception ex) { } } } return s; }
@Override public String toFormattedString(int flags) { if (getTimeLabel() != null) { return getTimeLabel(); } Period p = getJodaTimePeriod(); String s = (p != null) ? p.toString() : "PXX"; if ((flags & (FORMAT_ISO | FORMAT_TIMEX3_VALUE)) == 0) { String m = getMod(); if (m != null) { try { TimexMod tm = TimexMod.valueOf(m); if (tm.getSymbol() != null) { s = tm.getSymbol() + s; } } catch (Exception ex) { } } } return s; }
public String toFormattedString(int flags) { if (getTimeLabel() != null) { return getTimeLabel(); } Period p = getJodaTimePeriod(); String s = (p != null) ? p.toString() : "PXX"; if ((flags & (FORMAT_ISO | FORMAT_TIMEX3_VALUE)) == 0) { String m = getMod(); if (m != null) { try { TimexMod tm = TimexMod.valueOf(m); if (tm.getSymbol() != null) { s = tm.getSymbol() + s; } } catch (Exception ex) { } } } return s; }
@Override public Temporal intersect(Temporal t) { if (t == null) return this; if (t == TIME_UNKNOWN || t == DURATION_UNKNOWN) return this; if (t instanceof Time) { RelativeTime rt = new RelativeTime((Time) t, TemporalOp.INTERSECT, this); rt = (RelativeTime) rt.addMod(this.getMod()); return rt; } else if (t instanceof Range) { // return new TemporalSet(t, TemporalOp.INTERSECT, this); } else if (t instanceof Duration) { Duration d = (Duration) t; return intersect(d); } return null; }
public Temporal intersect(Temporal t) { if (t == null) return this; if (t == TIME_UNKNOWN || t == DURATION_UNKNOWN) return this; if (t instanceof Time) { RelativeTime rt = new RelativeTime((Time) t, TemporalOp.INTERSECT, this); rt = (RelativeTime) rt.addMod(this.getMod()); return rt; } else if (t instanceof Range) { // return new TemporalSet(t, TemporalOp.INTERSECT, this); } else if (t instanceof Duration) { Duration d = (Duration) t; return intersect(d); } return null; }
@Override public Temporal resolve(Time t, int flags) { if (t == null) return this; // No resolving to be done? if (base instanceof PartialTime) { PartialTime pt = (PartialTime) base.resolve(t,flags); List<Temporal> list = pt.toList(); if (list != null && list.size() >= n) { return list.get(n-1); } } else if (base instanceof Duration) { Duration d = ((Duration) base).multiplyBy(n-1); Time temp = t.getRange().begin(); return temp.offset(d,0).reduceGranularityTo(d.getDuration()); } return this; }
public Temporal resolve(Time t, int flags) { if (t == null) return this; // No resolving to be done? if (base instanceof PartialTime) { PartialTime pt = (PartialTime) base.resolve(t,flags); List<Temporal> list = pt.toList(); if (list != null && list.size() >= n) { return list.get(n-1); } } else if (base instanceof Duration) { Duration d = ((Duration) base).multiplyBy(n-1); Time temp = t.getRange().begin(); return temp.offset(d,0).reduceGranularityTo(d.getDuration()); } return this; }