Package ch.agent.t2.time

Examples of ch.agent.t2.time.Day


    TimeDomain contextDomain = context.getTimeDomain();
    if (beginExpr == null) {
      return new Range(contextDomain);
    } else {
      // be more permissive with context and fix ranges invalidated by conversion
      TimeIndex begin = beginExpr.getDate(context);
      TimeIndex end = endExpr.getDate(context);
      if (begin == null || end == null) // (consequence of empty context range when context needed)
        return new Range(contextDomain);
      else if (begin.compareTo(end) > 0 && (beginExpr.needContext() || endExpr.needContext()))
        return new Range(contextDomain);
      else {
View Full Code Here


       * So for higher resolutions, offsets are applied in the context
       * domain.
       */
      if (domain.compareResolutionTo(Resolution.DAY) < 0) {
        // apply the offset in the DAILY domain
        TimeIndex t = addOffset(TimeUtil.now(Day.DOMAIN));
        return t.convert(domain, Adjustment.DOWN);
      } else {
        // apply the offset in the context domain
        return addOffset(TimeUtil.now(domain));
      }
    }
View Full Code Here

   *
   * @param begin
   * @param keepBegin
   */
  private void eVRTodayLiteral(TimeDomain domain, DayExpression begin, boolean keepBegin) throws T2Exception {
    TimeIndex t = begin.getDate(domain);
    if (t.compareTo(time) > 0) {
      if (keepBegin)
        setTime(t);
      else {
        long diff = t.asLong() - time.asLong();
        long test = begin.offset + diff;
        if (Math.abs(test) <= Integer.MAX_VALUE)
          begin.incr((int)diff);
        else // change from TODAY to LITERAL
          begin.setTime(time);
View Full Code Here

   *
   * @param begin
   * @param keepBegin
   */
  private void eVRLiteralToday(TimeDomain domain, DayExpression begin, boolean keepBegin) throws T2Exception {
    TimeIndex t = getDate(domain);
    if (begin.time.compareTo(t) > 0) {
      if (keepBegin) {
        long diff = begin.time.asLong() - t.asLong();
        long test = offset + diff;
        if (Math.abs(test) <= Integer.MAX_VALUE)
          incr((int) diff);
        else
          // change from TODAY to LITERAL
View Full Code Here

        adjustment);
  }
 
  // convert "difficult" calendars to Day and increase resolution to milliseconds
  private static long yearOrMonthToMillisecSinceEpoch (long year, int month) throws T2Exception {
    TimeIndex m = Day.DOMAIN.time(year, month, 1, 0, 0, 0, 0, Adjustment.NONE);
    long index = m.asLong() * 24L * 3600000L;
    return index = index - epoch;
  }
View Full Code Here

    if (month == 0) {
      month = 1;
      daysInPeriod = isLeap(year) ? 366 : 365;
    } else
      daysInPeriod = daysInMonth(year, month);
    TimeIndex t = new Day(year, month, 1);
    DayOfWeek firstOfPeriod = t.getDayOfWeek();
    int workRank = rank;
    if (workRank < 0)
      workRank = max; // try the max
    int week1Offset = name.ordinal() - firstOfPeriod.ordinal();
    if (week1Offset < 0)
View Full Code Here

      int compareResols = getTimeDomain().getResolution().compareTo(otherTime.getTimeDomain().getResolution());
      if (compareResols == 0) {
        // convert  both to unrestricted domain
        TimeDomainDefinition def = new TimeDomainDefinition(null, getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex converted = convertOrThrowRTE(unrestrictedDomain, this);
        TimeIndex otherConverted = convertOrThrowRTE(unrestrictedDomain, otherTime);
        return converted.compareTo(otherConverted);
      } else if (compareResols < 0) {
        // convert  both to highest resolution
        TimeDomainDefinition def = new TimeDomainDefinition(null, otherTime.getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex converted = convertOrThrowRTE(unrestrictedDomain, this);
        return converted.compareTo(otherTime);
      } else {
        // convert  both to highest resolution
        TimeDomainDefinition def = new TimeDomainDefinition(null, getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex otherConverted = convertOrThrowRTE(unrestrictedDomain, otherTime);
        return compareTo(otherConverted);
      }
    }
  }
View Full Code Here

  }
 
  public void test_02() {
    try {
      UpdatableSeries<Double> s = db.getUpdatableSeries(SERIES, true).typeCheck(Double.class);
      TimeIndex t = s.getTimeDomain().time("2011-03-08");
      s.scanValue(t, "42");
      assertEquals(42.0, s.getValue(t));
    } catch (Exception e) {
      fail(e.toString());
    }
View Full Code Here

  }
 
  public void test_03() {
    try {
      Series<Double> s = db.getUpdatableSeries(SERIES, true).typeCheck(Double.class);
      TimeIndex t = s.getTimeDomain().time("2011-03-08");
      assertEquals(Double.NaN, s.getValue(t));
    } catch (Exception e) {
      fail(e.toString());
    }
  }
View Full Code Here

  }
 
  public void test_04() {
    try {
      UpdatableSeries<Double> s = db.getUpdatableSeries(SERIES, true).typeCheck(Double.class);
      TimeIndex t = s.getTimeDomain().time("2011-03-08");
      s.scanValue(t, "42");
      s.applyUpdates();
      assertEquals(42.0, s.getValue(t));
    } catch (Exception e) {
      fail(e.toString());
View Full Code Here

TOP

Related Classes of ch.agent.t2.time.Day

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.