This is used to allow special date arithmetic. A true value is returned if a change has been made.
Add Issue screen
public boolean ucAdjustWorkdays (int action, DateCalculator dc)
// Setup global vars used by ucAdjustWorkdays Calendar [] holidays = null; static final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000; // Setup methods used by ucAdjustWorkdays int myCompare (Calendar c1, Calendar c2) { // Note: This looks like it's trying to get the same day // by dividing by MILLIS_PER_DAY, // but that can cross date boundaries; // probably due to the TZ offset, don't want to change this // at the moment as it seeems to wrork for what is needed. long t1 = c1.getTimeInMillis() / MILLIS_PER_DAY; long t2 = c2.getTimeInMillis() / MILLIS_PER_DAY; if (t1 > t2) { return 1; } else if (t1 6) { // saturday st.add(Calendar.DATE, -1); start.add(Calendar.DATE, -1); } if (st.get(Calendar.DAY_OF_WEEK) == 1) { // sunday st.add(Calendar.DATE, -2); start.add(Calendar.DATE, -2); } } void advanceOneBusinessDay (Calendar st, Calendar start) { st.add(Calendar.DATE, 1); start.add(Calendar.DATE, 1); if (st.get(Calendar.DAY_OF_WEEK) == 7) { // saturday st.add(Calendar.DATE, 2); start.add(Calendar.DATE, 2); } if (st.get(Calendar.DAY_OF_WEEK) == 1) { // sunday st.add(Calendar.DATE, 1); start.add(Calendar.DATE, 1); } } public void setHolidays (Connection con, SesameSession session) throws Exception { holidays = new Calendar[9]; DbTime t = new DbTime(session, con); Calendar c = t.getUserNow() ; int i = 0; c.set(Calendar.AM_PM, Calendar.PM); // New Year’s Day Friday, January 1, 2010 c.set(2010, 0, 1, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // President’s Day Monday, February 15, 2010 c.set(2010, 1, 15); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Memorial Day Monday, May 31, 2010 c.set(2010, 4, 31); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Independence Day Monday, July 5, 2010 c.set(2010, 6, 5); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Labor Day Monday, September 6, 2010 c.set(2008, 8, 6); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Thanksgiving Day Thursday, November 25, 2010 c.set(2010,10, 25); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Day after Thanksgiving Friday, November 26, 2010 c.set(2010,10, 26); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Christmas Eve Friday, December 24, 2010 c.set(2010,11, 24); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // Christmas Day Monday, December 27, 2010 c.set(2010,11, 27); c.add(Calendar.DATE, 1); c.add(Calendar.DATE, -1); holidays[i++] = (Calendar) c.clone(); // for (i=0; i 0.d || start.before(end) && interval = 0 ) { s = i; break; } } // if all holidays are before start date, nothing to do. if (s == -1) { return false; } for (int i= holidays.length; i-- > 0;) { if (myCompare (holidays[i], en) 0 && myCompare (st, holidays[s-1]) == 0 ) { s--; num++; } } else { advanceOneBusinessDay(en, end); // if new day is a holiday, skip another one. if (e