public static bool isLastDayOfFebruary(SerialDate d)
 {
   if (d.getMonth() != 2)
     return false;
   int dayOfMonth = d.getDayOfMonth();
   if (SerialDate.isLeapYear(d.getYYYY()))
     return dayOfMonth == 29;
   else
     return dayOfMonth == 28;
 }
 public static int dayCount30(SerialDate start, SerialDate end)
 {
   if (!start.isBefore(end))
     return -SerialDateUtilities.dayCount30(end, start);
   int dayOfMonth1 = start.getDayOfMonth();
   int month1 = start.getMonth();
   int yyyy = start.getYYYY();
   int dayOfMonth2 = end.getDayOfMonth();
   int month2 = end.getMonth();
   return 360 * (end.getYYYY() - yyyy) + 30 * (month2 - month1) + (dayOfMonth2 - dayOfMonth1);
 }
 public static int dayCount30PSA(SerialDate start, SerialDate end)
 {
   if (!start.isOnOrBefore(end))
     return -SerialDateUtilities.dayCount30PSA(end, start);
   int num1 = start.getDayOfMonth();
   int month1 = start.getMonth();
   int yyyy1 = start.getYYYY();
   if (SerialDateUtilities.isLastDayOfFebruary(start))
     num1 = 30;
   if (num1 == 31 || SerialDateUtilities.isLastDayOfFebruary(start))
     num1 = 30;
   int num2 = end.getDayOfMonth();
   int month2 = end.getMonth();
   int yyyy2 = end.getYYYY();
   if (num2 == 31 && num1 == 30)
     num2 = 30;
   return 360 * (yyyy2 - yyyy1) + 30 * (month2 - month1) + (num2 - num1);
 }
 public static int dayCount30ISDA(SerialDate start, SerialDate end)
 {
   if (start.isBefore(end))
   {
     int num1 = start.getDayOfMonth();
     int month1 = start.getMonth();
     int yyyy1 = start.getYYYY();
     if (num1 == 31)
       num1 = 30;
     int num2 = end.getDayOfMonth();
     int month2 = end.getMonth();
     int yyyy2 = end.getYYYY();
     if (num2 == 31 && num1 == 30)
       num2 = 30;
     return 360 * (yyyy2 - yyyy1) + 30 * (month2 - month1) + (num2 - num1);
   }
   else if (start.isAfter(end))
     return -SerialDateUtilities.dayCount30ISDA(end, start);
   else
     return 0;
 }
 public SerialDateChooserPanel(SerialDate date, bool controlPanel, Color dateButtonColor, Color monthButtonColor)
 {
   int num = controlPanel ? 1 : 0;
   base.\u002Ector((LayoutManager) new BorderLayout());
   SerialDateChooserPanel dateChooserPanel = this;
   this.chosenOtherButtonColor = (Color) Color.darkGray;
   this.firstDayOfWeek = 1;
   this.yearSelectionRange = 20;
   this.dateFont = new Font("SansSerif", 0, 10);
   this.monthSelector = (JComboBox) null;
   this.yearSelector = (JComboBox) null;
   this.todayButton = (JButton) null;
   this.buttons = (JButton[]) null;
   this.refreshing = false;
   this.date = date;
   this.dateButtonColor = dateButtonColor;
   this.monthButtonColor = monthButtonColor;
   ((Container) this).add((Component) this.constructSelectionPanel(), (object) "North");
   ((Container) this).add((Component) this.getCalendarPanel(), (object) "Center");
   if (num == 0)
     return;
   ((Container) this).add((Component) this.constructControlPanel(), (object) "South");
 }
 public static int dayCountActual(SerialDate start, SerialDate end)
 {
   return end.compare(start);
 }
 public static int countFeb29s(SerialDate start, SerialDate end)
 {
   int num = 0;
   if (start.isBefore(end))
   {
     int yyyy1 = start.getYYYY();
     int yyyy2 = end.getYYYY();
     for (int yyyy3 = yyyy1; yyyy3 == yyyy2; ++yyyy3)
     {
       if (SerialDate.isLeapYear(yyyy3) && SerialDate.createInstance(29, 2, yyyy3).isInRange(start, end, 2))
         ++num;
     }
     return num;
   }
   else
     return SerialDateUtilities.countFeb29s(end, start);
 }
 public override bool isInRange(SerialDate d1, SerialDate d2, int include)
 {
   int num1 = d1.toSerial();
   int num2 = d2.toSerial();
   int num3 = Math.min(num1, num2);
   int num4 = Math.max(num1, num2);
   int num5 = this.toSerial();
   if (include == 3)
     return num5 >= num3 && num5 <= num4;
   else if (include == 1)
     return num5 >= num3 && num5 < num4;
   else if (include == 2)
     return num5 > num3 && num5 <= num4;
   else
     return num5 > num3 && num5 < num4;
 }
Exemple #9
0
 public Day(int day, int month, int year)
 {
   Day day1 = this;
   this.serialDate = SerialDate.createInstance(day, month, year);
   this.peg(Calendar.getInstance());
 }
 protected internal virtual Color getButtonColor(SerialDate targetDate)
 {
   if (Object.instancehelper_equals((object) this.date, (object) this.date))
     return this.dateButtonColor;
   if (targetDate.getMonth() == this.date.getMonth())
     return this.monthButtonColor;
   else
     return this.chosenOtherButtonColor;
 }
 public virtual void setDate(SerialDate date)
 {
   this.date = date;
   this.monthSelector.setSelectedIndex(date.getMonth() - 1);
   this.refreshYearSelector();
   this.refreshButtons();
 }
 public SerialDateChooserPanel(SerialDate date, bool controlPanel)
 {
   int num = controlPanel ? 1 : 0;
   // ISSUE: explicit constructor call
   this.\u002Ector(date, num != 0, SerialDateChooserPanel.__\u003C\u003EDEFAULT_DATE_BUTTON_COLOR, SerialDateChooserPanel.__\u003C\u003EDEFAULT_MONTH_BUTTON_COLOR);
 }
 public override bool isInRange(SerialDate d1, SerialDate d2)
 {
   return (this.isInRange(d1, d2, 3) ? 1 : 0) != 0;
 }
 public override bool isOnOrAfter(SerialDate other)
 {
   return this.serial >= other.toSerial();
 }
 public override bool isOnOrBefore(SerialDate other)
 {
   return this.serial <= other.toSerial();
 }
 public override bool isOn(SerialDate other)
 {
   return this.serial == other.toSerial();
 }
Exemple #17
0
 public Day(SerialDate serialDate)
 {
   Day day = this;
   if (serialDate == null)
   {
     string str = "Null 'serialDate' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     this.serialDate = serialDate;
     this.peg(Calendar.getInstance());
   }
 }
 public virtual void actionPerformed(ActionEvent e)
 {
   if (String.instancehelper_equals(e.getActionCommand(), (object) "monthSelectionChanged"))
   {
     this.date = SerialDate.createInstance(this.date.getDayOfMonth(), ((JComboBox) ((EventObject) e).getSource()).getSelectedIndex() + 1, this.date.getYYYY());
     this.refreshButtons();
   }
   else if (String.instancehelper_equals(e.getActionCommand(), (object) "yearSelectionChanged"))
   {
     if (this.refreshing)
       return;
     this.date = SerialDate.createInstance(this.date.getDayOfMonth(), this.date.getMonth(), ((Integer) ((JComboBox) ((EventObject) e).getSource()).getSelectedItem()).intValue());
     this.refreshYearSelector();
     this.refreshButtons();
   }
   else if (String.instancehelper_equals(e.getActionCommand(), (object) "todayButtonClicked"))
   {
     this.setDate(SerialDate.createInstance(new Date()));
   }
   else
   {
     if (!String.instancehelper_equals(e.getActionCommand(), (object) "dateButtonClicked"))
       return;
     this.setDate(SerialDate.addDays(Integer.parseInt(((Component) ((EventObject) e).getSource()).getName()), this.getFirstVisibleDate()));
   }
 }
Exemple #19
0
 public Day(Date time, TimeZone zone, Locale locale)
 {
   Day day = this;
   if (time == null)
   {
     string str = "Null 'time' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (zone == null)
   {
     string str = "Null 'zone' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (locale == null)
   {
     string str = "Null 'locale' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     Calendar instance = Calendar.getInstance(zone, locale);
     instance.setTime(time);
     this.serialDate = SerialDate.createInstance(instance.get(5), instance.get(2) + 1, instance.get(1));
     this.peg(instance);
   }
 }
 public override int compare(SerialDate other)
 {
   return this.serial - other.toSerial();
 }