TsData implements Cloneable, Iterable<TsObservation>, IReadDataBlock { public TsData extendTo(final Day lastday) { TsPeriod s = new TsPeriod(start.getFrequency(), lastday); if (!lastday.equals(s.lastday())) { s.move(-1); } int n = s.minus(start) + 1; return extend(0, n - vals.length); } TsData(final TsDomain dom);  TsData(final TsDomain dom, double val);   TsData(final TsFrequency freq, final int beg, final int count);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final double[] data, boolean copydata);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final int count);  TsData(final TsPeriod start, final double[] data, boolean copydata);  TsData(final TsPeriod start, final int count);  TsData(final TsPeriod start, final IReadDataBlock vals); static TsData add(final double d, final TsData ts); static TsData add(final TsData tsl, final TsData tsr); static TsData divide(final double d, final TsData ts); static TsData divide(final TsData tsl, final TsData tsr); static TsData multiply(final double d, final TsData ts); static TsData multiply(final TsData tsl, final TsData tsr); static TsData subtract(double d, final TsData ts); static TsData subtract(final TsData tsl, final TsData tsr); static TsData random(TsFrequency freq); static TsData random(TsFrequency freq, int seed); void randomAirline(); double distance(TsData s); @Override void copyTo(double[] buffer, int start); @Override IReadDataBlock rextract(int start, int length); TsData abs(); TsData changeFrequency(final TsFrequency newfreq,
            final TsAggregationType conversion, final boolean complete); TsData chs(); TsData cleanExtremities(); @Override TsData clone(); TsData delta(final int lag); TsData delta(final int lag, final int power); TsData div(final double d); TsData div(final TsData ts); TsData drop(final int nfirst, final int nlast); TsData fullYears(); TsData exp(); TsData round(int ndec); TsData extend(final int nbefore, final int nafter); TsData extendTo(final Day lastday); TsData fittoDomain(final TsDomain dom); boolean isMissing(final int idx); void setMissing(final int idx); @Override double get(final int idx); @NewObject TsDomain getDomain(); @Deprecated Values getValues(); @NewObject TsPeriod getEnd(); TsFrequency getFrequency(); @NewObject TsPeriod getLastPeriod(); @Override int getLength(); int getObsCount(); int getMissingValuesCount(); boolean hasMissingValues(); @NewObject TsPeriod getStart(); TsData index(final TsPeriod refperiod, final double refvalue); TsData inv(); boolean isEmpty(); @Override Iterator<TsObservation> iterator(); Stream<TsObservation> stream(); TsData lag(int nperiods); TsData lead(final int nperiods); TsData log(); TsData log(final double b); TsData sqrt(); TsData minus(final double d); TsData minus(final TsData ts); TsData movingAverage(final double[] weights, final boolean bcentred,
            final boolean bnormalized); TsData movingMedian(final int nperiods, final boolean bcentred); TsData pctVariation(final int lag); TsData plus(final double d); TsData plus(final TsData ts); TsData pow(final double e); TsData select(final TsPeriodSelector ps); void set(final int idx, final double value); TsData times(final double d); TsData times(final TsData ts); TsData update(final TsData ts); static TsData concatenate(TsData l, TsData r); void removeMean(); void normalize(); double get(TsPeriod period); void set(TsPeriod period, double value); @Unsafe double[] internalStorage(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); boolean equals(TsData other); @Override double computeRecursively(final double initial, DoubleBinaryOperator fn); void apply(DoubleUnaryOperator fn); void applyIf(DoublePredicate pred, DoubleUnaryOperator fn); void applyOnFinite(DoubleUnaryOperator fn); void applyRecursively(final double initial, DoubleBinaryOperator fn); @Override boolean check(DoublePredicate pred); @Override int count(DoublePredicate pred); @Override int first(DoublePredicate pred); @Override int last(DoublePredicate pred); TsData transform(DoubleUnaryOperator fn); TsData transformFinite(DoubleUnaryOperator fn); TsData autoTransform(int lag, DoubleBinaryOperator fn); void apply(IReadDataBlock x, DoubleBinaryOperator fn); void applyOnFinite(IReadDataBlock x, DoubleBinaryOperator fn); void set(DoubleSupplier fn); void setIf(DoublePredicate pred, DoubleSupplier fn); void set(IntToDoubleFunction fn); void set(IReadDataBlock x, DoubleUnaryOperator fn); void set(IReadDataBlock x, IReadDataBlock y, DoubleBinaryOperator fn); static TsData computeOnIntersection(final TsData tsl, final TsData tsr, final DoubleBinaryOperator fn);  }
@Test public void testExtendTo() { TsData s = new TsData(TsFrequency.Monthly, 1980, 0, 12); Day d0 = new Day(1980, Month.December, 30); assertTrue(s.extendTo(d0).getLastPeriod().lastday().equals(d0)); Day d1 = new Day(1980, Month.December, 29); assertTrue(s.extendTo(d1).getLastPeriod().lastday().isBefore(d1)); Day d2 = new Day(1981, Month.January, 1); assertTrue(s.extendTo(d2).getLastPeriod().lastday().equals(d0)); }