Ejemplo n.º 1
0
  public static Stella_Object accessCalendarDateSlotValue(
      CalendarDate self, Symbol slotname, Stella_Object value, boolean setvalueP) {
    if (slotname == Stella.SYM_STELLA_MODIFIED_JULIAN_DAY) {
      if (setvalueP) {
        self.modifiedJulianDay = ((IntegerWrapper) (value)).wrapperValue;
      } else {
        value = IntegerWrapper.wrapInteger(self.modifiedJulianDay);
      }
    } else if (slotname == Stella.SYM_STELLA_TIME_MILLIS) {
      if (setvalueP) {
        self.timeMillis = ((IntegerWrapper) (value)).wrapperValue;
      } else {
        value = IntegerWrapper.wrapInteger(self.timeMillis);
      }
    } else {
      {
        OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

        stream000.nativeStream.print("`" + slotname + "' is not a valid case option");
        throw ((StellaException)
            (StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
      }
    }
    return (value);
  }
Ejemplo n.º 2
0
  public void printObject(java.io.PrintStream stream) {
    {
      CalendarDate self = this;

      self.printCalendarDate(stream);
    }
  }
Ejemplo n.º 3
0
  public static CalendarDate newCalendarDate() {
    {
      CalendarDate self = null;

      self = new CalendarDate();
      self.timeMillis = Stella.NULL_INTEGER;
      self.modifiedJulianDay = Stella.NULL_INTEGER;
      return (self);
    }
  }
Ejemplo n.º 4
0
  /**
   * Returns a string representation of <code>date</code> adjusted for <code>timezone</code>. The
   * Format is YYYY-MMM-DD hh:mm:ss z.z, where MMM is a three letter English abbreviation of the
   * month if <code>numericMonthP</code> is <code>false</code> and a two digit numeric value if
   * <code>numericMonthP</code> is <code>true</code>. The timezone as a float offset z.z is included
   * if <code>includeTimezoneP</code> is <code>true</code>.
   *
   * <p>Recommended values for the flags are <code>false</code> and <code>true</code> respectively.
   *
   * @param timezone
   * @param numericMonthP
   * @param includeTimezoneP
   * @return String
   */
  public String calendarDateToString(
      double timezone, boolean numericMonthP, boolean includeTimezoneP) {
    {
      CalendarDate date = this;

      return (date.calendarDateToDateString(timezone, numericMonthP)
          + " "
          + date.calendarDateToTimeString(timezone, includeTimezoneP, true, false));
    }
  }
Ejemplo n.º 5
0
  /**
   * Returns a decoded time object for <code>date</code> interpreted in <code>timezone</code> <code>
   * timezone</code> is the number of hours added to UTC to get local time. It is in the range -12.0
   * to +14.0 where UTC is zone 0.0
   *
   * @param timezone
   * @return DecodedDateTime
   */
  public DecodedDateTime decodeCalendarDate(double timezone) {
    {
      CalendarDate date = this;

      {
        int hour = Stella.NULL_INTEGER;
        int min = Stella.NULL_INTEGER;
        int sec = Stella.NULL_INTEGER;
        int millis = Stella.NULL_INTEGER;

        {
          Object[] caller_MV_returnarray = new Object[3];

          hour = date.getTime(timezone, caller_MV_returnarray);
          min = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
          sec = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
          millis = ((int) (((IntegerWrapper) (caller_MV_returnarray[2])).wrapperValue));
        }
        {
          int year = Stella.NULL_INTEGER;
          int month = Stella.NULL_INTEGER;
          int day = Stella.NULL_INTEGER;
          Keyword dow = null;

          {
            Object[] caller_MV_returnarray = new Object[3];

            year = date.getCalendarDate(timezone, caller_MV_returnarray);
            month = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
            day = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
            dow = ((Keyword) (caller_MV_returnarray[2]));
          }
          {
            DecodedDateTime self000 = DecodedDateTime.newDecodedDateTime();

            self000.dateTimeMillis = ((double) (millis));
            self000.dateTimeSecond = sec;
            self000.dateTimeMinute = min;
            self000.dateTimeHour = hour;
            self000.dateTimeDay = day;
            self000.dateTimeMonth = month;
            self000.dateTimeYear = year;
            self000.dateTimeZone = timezone;
            self000.dateTimeDow = dow;
            {
              DecodedDateTime value000 = self000;

              return (value000);
            }
          }
        }
      }
    }
  }
Ejemplo n.º 6
0
  /**
   * Create a calendar date with current time and date.
   *
   * @return CalendarDate
   */
  public static CalendarDate makeCurrentDateTime() {
    {
      int year = Stella.NULL_INTEGER;
      int month = Stella.NULL_INTEGER;
      int day = Stella.NULL_INTEGER;
      Keyword dow = null;
      int hour = Stella.NULL_INTEGER;
      int minute = Stella.NULL_INTEGER;
      int second = Stella.NULL_INTEGER;
      int millisecond = Stella.NULL_INTEGER;

      {
        Object[] caller_MV_returnarray = new Object[7];

        year = Stella.getCurrentDateTime(caller_MV_returnarray);
        month = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
        day = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
        dow = ((Keyword) (caller_MV_returnarray[2]));
        hour = ((int) (((IntegerWrapper) (caller_MV_returnarray[3])).wrapperValue));
        minute = ((int) (((IntegerWrapper) (caller_MV_returnarray[4])).wrapperValue));
        second = ((int) (((IntegerWrapper) (caller_MV_returnarray[5])).wrapperValue));
        millisecond = ((int) (((IntegerWrapper) (caller_MV_returnarray[6])).wrapperValue));
      }
      dow = dow;
      return (CalendarDate.makeDateTime(year, month, day, hour, minute, second, millisecond, 0.0));
    }
  }
Ejemplo n.º 7
0
  /**
   * Returns the time part of the string representation of <code>date</code> adjusted for <code>
   * timezone</code>. The timezone is included in the string if <code>includeTimezoneP</code> is
   * <code>true</code>. The value <code>true</code> is recommended. Milliseconds will be included if
   * <code>includeMillisP</code> is <code>true</code>. Hours will be zero-padded to length 2 if
   * <code>padHoursP</code> is <code>true</code>.
   *
   * @param timezone
   * @param includeTimezoneP
   * @param includeMillisP
   * @param padHoursP
   * @return String
   */
  public String calendarDateToTimeString(
      double timezone, boolean includeTimezoneP, boolean includeMillisP, boolean padHoursP) {
    {
      CalendarDate date = this;

      {
        int hours = Stella.NULL_INTEGER;
        int minutes = Stella.NULL_INTEGER;
        int seconds = Stella.NULL_INTEGER;
        int milli = Stella.NULL_INTEGER;

        {
          Object[] caller_MV_returnarray = new Object[3];

          hours = date.getTime(timezone, caller_MV_returnarray);
          minutes = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
          seconds = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
          milli = ((int) (((IntegerWrapper) (caller_MV_returnarray[2])).wrapperValue));
        }
        {
          String timezoneString =
              (includeTimezoneP
                  ? (((timezone == 0.0) ? " UTC" : (" " + Native.floatToString(timezone))))
                  : "");
          String milliString =
              (includeMillisP
                  ? ("."
                      + Stella.formatWithPadding(
                          Native.integerToString(milli), 3, '0', Stella.KWD_RIGHT, false))
                  : "");

          return (((padHoursP
                  ? Stella.formatWithPadding(
                      Native.integerToString(hours), 2, '0', Stella.KWD_RIGHT, false)
                  : Native.integerToString(hours)))
              + ":"
              + Stella.formatWithPadding(
                  Native.integerToString(minutes), 2, '0', Stella.KWD_RIGHT, false)
              + ":"
              + Stella.formatWithPadding(
                  Native.integerToString(seconds), 2, '0', Stella.KWD_RIGHT, false)
              + milliString
              + timezoneString);
        }
      }
    }
  }
Ejemplo n.º 8
0
  public void printCalendarDate(java.io.PrintStream stream) {
    {
      CalendarDate date = this;

      if (((Boolean) (Stella.$PRINTREADABLYp$.get())).booleanValue()) {
        stream.print("\"");
      } else {
        stream.print("<" + date.modifiedJulianDay + " ");
      }
      stream.print(date.calendarDateToString(0.0, false, false));
      if (((Boolean) (Stella.$PRINTREADABLYp$.get())).booleanValue()) {
        stream.print(" UTC\"");
      } else {
        stream.print(" UTC>");
      }
    }
  }
Ejemplo n.º 9
0
  public static CalendarDate nativeDateTimeToCalendarDate(long date) {
    {
      int mjd = 0;
      int millis = 0;

      mjd = (int) ((date / 86400000) + 40588);
      millis = (int) (date % 86400000);
      return (CalendarDate.makeCalendarDate(mjd, millis));
    }
  }
Ejemplo n.º 10
0
  /**
   * Create a calendar date with the specified components. <code>year</code> must be the complete
   * year (i.e., a year of 98 is 98 A.D in the 1st century). <code>timezone</code> is a real number
   * in the range -12.0 to +14.0 where UTC is zone 0.0; The number is the number of hours to add to
   * UTC to arrive at local time.
   *
   * @param year
   * @param month
   * @param day
   * @param hour
   * @param minute
   * @param second
   * @param millis
   * @param timezone
   * @return CalendarDate
   */
  public static CalendarDate makeDateTime(
      int year, int month, int day, int hour, int minute, int second, int millis, double timezone) {
    {
      int time = (hour * Stella.MILLIS_PER_HOUR) + (minute * 60000) + (second * 1000) + millis;

      time = ((int) (time - (timezone * Stella.MILLIS_PER_HOUR)));
      return (CalendarDate.makeCalendarDate(
          Stella.julianDayToModifiedJulianDay(Stella.computeJulianDay(year, month, day)), time));
    }
  }
Ejemplo n.º 11
0
  /**
   * Returns the date part of the string representation of <code>date</code> adjusted for <code>
   * timezone</code>. Format is YYYY-MMM-DD, where MMM is a three letter English abbreviation of the
   * month if <code>numericMonthP</code> is <code>false</code> and a two digit numeric value if
   * <code>numericMonthP</code> is <code>true</code>. The value <code>false</code> is recommended.
   *
   * @param timezone
   * @param numericMonthP
   * @return String
   */
  public String calendarDateToDateString(double timezone, boolean numericMonthP) {
    {
      CalendarDate date = this;

      {
        int year = Stella.NULL_INTEGER;
        int month = Stella.NULL_INTEGER;
        int day = Stella.NULL_INTEGER;
        Keyword dow = null;

        {
          Object[] caller_MV_returnarray = new Object[3];

          year = date.getCalendarDate(timezone, caller_MV_returnarray);
          month = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
          day = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
          dow = ((Keyword) (caller_MV_returnarray[2]));
        }
        dow = dow;
        {
          String yearString =
              ((year < 0)
                  ? (Native.integerToString(0 - year) + "BC")
                  : Native.integerToString(year));
          String monthString =
              (numericMonthP
                  ? Stella.formatWithPadding(
                      Native.integerToString(month), 2, '0', Stella.KWD_RIGHT, false)
                  : StringWrapper.unwrapString(
                      ((StringWrapper) ((Stella.$MONTH_ABBREVIATION_VECTOR$.theArray)[month]))));

          return (yearString
              + "-"
              + monthString
              + "-"
              + Stella.formatWithPadding(
                  Native.integerToString(day), 2, '0', Stella.KWD_RIGHT, false));
        }
      }
    }
  }
Ejemplo n.º 12
0
  /**
   * Returns an ISO-8601 string representation of <code>date</code> adjusted for <code>timezone
   * </code>. The Format is YYYY-MM-DDThh:mm:ss z:zz. The timezone as an offset hh:mm is included if
   * <code>includeTimezoneP</code> is <code>true</code>.
   *
   * <p>Recommended values for the flag is <code>true</code>.
   *
   * @param timezone
   * @param includeTimezoneP
   * @return String
   */
  public String calendarDateToIso8601String(double timezone, boolean includeTimezoneP) {
    {
      CalendarDate date = this;

      {
        String tzString = "";

        if (includeTimezoneP) {
          if (timezone == 0.0) {
            tzString = "Z";
          } else {
            tzString = Stella.timeZoneFormat60(timezone);
          }
        }
        return (date.calendarDateToDateString(timezone, true)
            + "T"
            + date.calendarDateToTimeString(timezone, false, false, true)
            + tzString);
      }
    }
  }
Ejemplo n.º 13
0
  public static CalendarDate makeCalendarDate(int day, int time) {
    while (time < 0) {
      time = time + Stella.MILLIS_PER_DAY;
      day = day - 1;
    }
    while (time > Stella.MILLIS_PER_DAY) {
      time = time - Stella.MILLIS_PER_DAY;
      day = day + 1;
    }
    {
      CalendarDate self000 = CalendarDate.newCalendarDate();

      self000.modifiedJulianDay = day;
      self000.timeMillis = time;
      {
        CalendarDate value000 = self000;

        return (value000);
      }
    }
  }
Ejemplo n.º 14
0
  /**
   * Returns a calendar date object representing the date and time parsed from the <code>inputDate
   * </code> string. Default values for missing fields and the interpretation of relative references
   * come from <code>defaultDate</code>. If the <code>defaultDate</code> is <code>null</code>, the
   * current date will be used. If a null set of defaults is desired, use <code>
   * $NULL_DECODED_DATE_TIME$</code>. If no valid parse is found, <code>null</code> is returned.
   *
   * @param inputDate
   * @param defaultDate
   * @return CalendarDate
   */
  public static CalendarDate stringToCalendarDateWithDefault(
      String inputDate, DecodedDateTime defaultDate) {
    if (defaultDate == null) {
      return (CalendarDate.stringToCalendarDate(inputDate));
    } else {
      {
        DecodedDateTime dateTime =
            DecodedDateTime.parseDateTimeRelativeToBase(
                inputDate, defaultDate, 0, Stella.NULL_INTEGER, false, true);

        if (dateTime == null) {
          return (null);
        } else {
          return (dateTime.encodeCalendarDate());
        }
      }
    }
  }