This method has not been implemented (simply returns false), which is causing a problem with the method SerialDateUtilities.countFeb29s().
This means that I cannot calculate an accurate Actual/Actual day count fraction
It seems like this would be fairly easy to implement using the compareTo() method, but nobody bothered to.
SpreadsheetDate.isInRange()
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Here's what I've written (not tested yet!):
Code: Select all
/**
* Returns <code>true</code> if this {@link SerialDate} is within the specified range
* (INCLUSIVE). The date order of d1 and d2 is not important.
*
* @param d1 a boundary date for the range.
* @param d2 the other boundary date for the range.
*
* @return A boolean.
*/
public boolean isInRange(SerialDate d1, SerialDate d2) {
return isInRange(d1, d2, SerialDate.INCLUDE_BOTH);
}
/**
* Returns true if this SerialDate is within the specified range (caller
* specifies whether or not the end-points are included). The order of d1
* and d2 is not important.
*
* @param d1 one boundary date for the range.
* @param d2 a second boundary date for the range.
* @param include a code that controls whether or not the start and end dates are
* included in the range.
*
* @return <code>true</code> if this SerialDate is within the specified range.
*/
public boolean isInRange(SerialDate d1, SerialDate d2, int include) {
int s1 = d1.toSerial();
int s2 = d2.toSerial();
int start = Math.min(s1, s2);
int end = Math.max(s1, s2);
int s = toSerial();
if (include == SerialDate.INCLUDE_BOTH) {
return (s >= start && s <= end);
}
else if (include == SerialDate.INCLUDE_FIRST){
return (s >= start && s < end);
}
else if (include == SerialDate.INCLUDE_SECOND) {
return (s > start && s <= end);
}
else {
return (s > start && s < end);
}
}
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program