From: SourceForge.net <no...@so...> - 2009-05-21 15:08:31
|
Bugs item #2794868, was opened at 2009-05-21 16:08 Message generated for change (Tracker Item Submitted) made by sourceforgebob You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=2794868&group_id=15494 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: jcommon Group: 1.0.x Status: Open Resolution: None Priority: 5 Private: No Submitted By: bob messenger (sourceforgebob) Assigned to: Nobody/Anonymous (nobody) Summary: Serial Dates Are Being Calculated Incorrectly Initial Comment: I think I've found a pretty major bug in the 'private int calcSerial(final int d, final int m, final int y)' function of the SpreadsheetDate class in the jcommon library. if (m > MonthConstants.FEBRUARY) { should be replaced with either: if (m >= MonthConstants.FEBRUARY) { or if (m > 1) { To avoid dependency, the arguments specifically have to be zero based months. Maybe something like this: public static int calcSerial(final int d, final int m, final int y) { final int yy = ((y - 1900) * 365) + SerialDate.leapYearCount(y - 1); int mm = AGGREGATE_DAYS_TO_END_OF_PRECEDING_MONTH[m]; if (m > 1 && SerialDate.isLeapYear(y)) return yy + mm + d + 2; return yy + mm + d + 1; } Cheers, Bob ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=2794868&group_id=15494 |
From: SourceForge.net <no...@so...> - 2009-05-21 15:09:48
|
Bugs item #2794868, was opened at 2009-05-21 16:08 Message generated for change (Settings changed) made by sourceforgebob You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=2794868&group_id=15494 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: jcommon Group: 1.0.x Status: Open Resolution: None >Priority: 9 Private: No Submitted By: bob messenger (sourceforgebob) Assigned to: Nobody/Anonymous (nobody) Summary: Serial Dates Are Being Calculated Incorrectly Initial Comment: I think I've found a pretty major bug in the 'private int calcSerial(final int d, final int m, final int y)' function of the SpreadsheetDate class in the jcommon library. if (m > MonthConstants.FEBRUARY) { should be replaced with either: if (m >= MonthConstants.FEBRUARY) { or if (m > 1) { To avoid dependency, the arguments specifically have to be zero based months. Maybe something like this: public static int calcSerial(final int d, final int m, final int y) { final int yy = ((y - 1900) * 365) + SerialDate.leapYearCount(y - 1); int mm = AGGREGATE_DAYS_TO_END_OF_PRECEDING_MONTH[m]; if (m > 1 && SerialDate.isLeapYear(y)) return yy + mm + d + 2; return yy + mm + d + 1; } Cheers, Bob ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=2794868&group_id=15494 |
From: SourceForge.net <no...@so...> - 2009-05-22 01:44:02
|
Bugs item #2794868, was opened at 2009-05-21 15:08 Message generated for change (Comment added) made by mungady You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=2794868&group_id=15494 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: jcommon Group: 1.0.x >Status: Closed >Resolution: Works For Me >Priority: 5 Private: No Submitted By: bob messenger (sourceforgebob) >Assigned to: David Gilbert (mungady) Summary: Serial Dates Are Being Calculated Incorrectly Initial Comment: I think I've found a pretty major bug in the 'private int calcSerial(final int d, final int m, final int y)' function of the SpreadsheetDate class in the jcommon library. if (m > MonthConstants.FEBRUARY) { should be replaced with either: if (m >= MonthConstants.FEBRUARY) { or if (m > 1) { To avoid dependency, the arguments specifically have to be zero based months. Maybe something like this: public static int calcSerial(final int d, final int m, final int y) { final int yy = ((y - 1900) * 365) + SerialDate.leapYearCount(y - 1); int mm = AGGREGATE_DAYS_TO_END_OF_PRECEDING_MONTH[m]; if (m > 1 && SerialDate.isLeapYear(y)) return yy + mm + d + 2; return yy + mm + d + 1; } Cheers, Bob ---------------------------------------------------------------------- >Comment By: David Gilbert (mungady) Date: 2009-05-22 01:43 Message: I think the code is correct, but if you think otherwise then please provide an example where the method returns the wrong serial number for a date (it is intended that this class should return the same integer value that Excel stores for dates). The code is trying to account for the leap day in February, if the current year is a leap year. We don't need to count this in 'mm' unless the date is after Feb 29, so we just test that the month is March or later - that is, m > MonthConstants.FEBRUARY. I'll close the bug report - feel free to reopen it if you can supply a failing test case. Best regards, Dave Gilbert JFreeChart Project Leader ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=2794868&group_id=15494 |