return this; } else { return new CompositePartialTime(this, p, poy, dow, tod);
private static Range getIntersectedRange(CompositePartialTime cpt, Range r, Duration d) { Time beginTime = r.beginTime(); Time endTime = r.endTime(); if (beginTime != TIME_UNKNOWN && endTime != TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = cpt.intersect(r.endTime()); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else if (beginTime != TIME_UNKNOWN && endTime == TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = t1.add(d); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else { throw new RuntimeException("Unsupported range: " + r); } }
StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getPeriod();
public Range getRange(int flags, Duration granularity) { Duration d = getDuration(); if (tod != null) { Range r = tod.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, dow, null); Time t1 = cpt.intersect(r.beginTime()); Time t2 = cpt.intersect(r.endTime()); return new Range(t1, t2, d); } else { Range r = dow.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, dow, null); Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); Time t2 = cpt.intersect(r.endTime()); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); Range r = poy.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, null, null); Time t1 = cpt.intersect(r.beginTime()); Time t2 = cpt.intersect(r.endTime()); return new Range(t1, t2, d); } else {
public Range getRange(int flags, Duration granularity) { Duration d = getDuration(); if (tod != null) { Range r = tod.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, dow, null); Time t1 = cpt.intersect(r.beginTime()); Time t2 = cpt.intersect(r.endTime()); return new Range(t1, t2, d); } else { Range r = dow.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, dow, null); Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); Time t2 = cpt.intersect(r.endTime()); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); Range r = poy.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, null, null); Time t1 = cpt.intersect(r.beginTime()); Time t2 = cpt.intersect(r.endTime()); return new Range(t1, t2, d); } else {
StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getPeriod();
return this; } else { return new CompositePartialTime(this, p, poy, dow, tod);
return this; } else { return new CompositePartialTime(this, p, poy, dow, tod);
public DateTimeFormatter getFormatter(int flags) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); boolean hasDate = appendDateFormats(builder, flags); if (poy != null) { if (!JodaTimeUtils.hasField(base, DateTimeFieldType.monthOfYear())) { if (hasTime()) { if (!hasDate) { builder.clear(); appendTimeFormats(builder, flags); } else if (tod != null) { if (!hasDate) {
public DateTimeFormatter getFormatter(int flags) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); boolean hasDate = appendDateFormats(builder, flags); if (poy != null) { if (!JodaTimeUtils.hasField(base, DateTimeFieldType.monthOfYear())) { if (hasTime()) { if (!hasDate) { builder.clear(); appendTimeFormats(builder, flags); } else if (tod != null) { if (!hasDate) {
@Override public DateTimeFormatter getFormatter(int flags) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); boolean hasDate = appendDateFormats(builder, flags); if (poy != null) { if (!JodaTimeUtils.hasField(base, DateTimeFieldType.monthOfYear())) { if (hasTime()) { if (!hasDate) { builder.clear(); appendTimeFormats(builder, flags); } else if (tod != null) { if (!hasDate) {
return this; } else { return new CompositePartialTime(this, p, poy, dow, tod);
StandardTemporalType tlt = getStandardTemporalType(); if (tlt != null) { return tlt.getPeriod();
public Time intersect(Time t) { if (t == null || t == TIME_UNKNOWN) return this; if (base == null) return t; if (t instanceof PartialTime) { Pair<PartialTime,PartialTime> compatible = getCompatible(this, (PartialTime) t); if (compatible == null) { return null; } Partial p = JodaTimeUtils.combine(compatible.first.base, compatible.second.base); if (t instanceof CompositePartialTime) { CompositePartialTime cpt = (CompositePartialTime) t; Time ntod = Time.intersect(tod, cpt.tod); Time ndow = Time.intersect(dow, cpt.dow); Time npoy = Time.intersect(poy, cpt.poy); if (ntod == null && (tod != null || cpt.tod != null)) return null; if (ndow == null && (dow != null || cpt.dow != null)) return null; if (npoy == null && (poy != null || cpt.poy != null)) return null; return new CompositePartialTime(this, p, npoy, ndow, ntod); } else { return new CompositePartialTime(this, p, poy, dow, tod); } } else { return super.intersect(t); } }
return t; if (t instanceof PartialTime) { Pair<PartialTime,PartialTime> compatible = getCompatible(this, (PartialTime) t); if (compatible == null) { return null; if (npoy == null && (poy != null || cpt.poy != null)) return null; return new CompositePartialTime(this, p, npoy, ndow, ntod); } else { return new CompositePartialTime(this, p, poy, dow, tod);
public Time resolve(Time refTime, int flags) { CompositePartialTime cpt = makeComposite(new PartialTime(this, new Partial()), this); if (cpt != null) { return cpt.resolve(refTime, flags); } Time groundedBase = null; if (base == TIME_REF) { groundedBase = refTime; } else if (base != null) { groundedBase = base.resolve(refTime, flags).getTime(); } Range groundedRange = null; if (range != null) { groundedRange = range.resolve(refTime, flags).getRange(); } /* if (groundedRange == range && groundedBase == base) { return this; } */ final TimeLabel tl = getTimeLabel(); InexactTime t = new InexactTime(groundedBase, duration, groundedRange) { public TimeLabel getTimeLabel() { return tl; } }; t.mod = mod; return t; }
@Override public Range getRange(int flags, Duration granularity) { Duration d = getDuration(); if (tod != null) { Range r = tod.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, dow, null); return getIntersectedRange(cpt, r, d); } else { return super.getRange(flags, granularity); Range r = dow.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, dow, null); return getIntersectedRange(cpt, r, d); } else { return super.getRange(flags, granularity); Range r = poy.getRange(flags, granularity); if (r != null) { CompositePartialTime cpt = new CompositePartialTime(this, poy, null, null); return getIntersectedRange(cpt, r, d); } else { return super.getRange(flags, granularity);
public Time intersect(Time t) { if (t == null || t == TIME_UNKNOWN) return this; if (base == null) return t; if (t instanceof PartialTime) { if (!isCompatible((PartialTime) t)) { return null; } Partial p = JodaTimeUtils.combine(this.base, ((PartialTime) t).base); if (t instanceof CompositePartialTime) { CompositePartialTime cpt = (CompositePartialTime) t; Time ntod = Time.intersect(tod, cpt.tod); Time ndow = Time.intersect(dow, cpt.dow); Time npoy = Time.intersect(poy, cpt.poy); if (ntod == null && (tod != null || cpt.tod != null)) return null; if (ndow == null && (dow != null || cpt.dow != null)) return null; if (npoy == null && (poy != null || cpt.poy != null)) return null; return new CompositePartialTime(this, p, npoy, ndow, ntod); } else { return new CompositePartialTime(this, p, poy, dow, tod); } } else { return super.intersect(t); } }
private static Range getIntersectedRange(CompositePartialTime cpt, Range r, Duration d) { Time beginTime = r.beginTime(); Time endTime = r.endTime(); if (beginTime != TIME_UNKNOWN && endTime != TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = cpt.intersect(r.endTime()); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else if (beginTime != TIME_UNKNOWN && endTime == TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = t1.add(d); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else { throw new RuntimeException("Unsupported range: " + r); } }
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; }