[kaffe] GregorianCalendar bug?

Dalibor Topic robilad at yahoo.com
Fri Oct 11 07:42:02 PDT 2002


Hallo Helmer,

--- Helmer Krämer <hkraemer at freenet.de> wrote:
> 
> Hi all,
> 
> while trying to get Tomcat 4.0.4 to run with kaffe
> CVS,
> I stumbled across the following line in
> GregorianCalendar.java:
> 
> int wday = up ? (int)((EPOCH_WDAY + days + 1) %
> DAYSPERWEEK) : (int)(((EPOCH_WDAY - days + 1) %
> DAYSPERWEEK) + DAYSPERWEEK);
> 
> which is supposed to calculate the day of the week
> (up is true
> when calculating something after 1.1. 1970,
> otherwise false).
> 
> I think this should be something like this:
> 
> int wday = up ? (int)((EPOCH_WDAY + days) %
> DAYSPERWEEK + 1) : (int)(((EPOCH_WDAY - days) %
> DAYSPERWEEK + 1));
> 
> because adding 1 before doing the modulo gives
> incorrect results for
> saturdays (for saturdays EPOCH_WDAY+days will be 6,
> so wday will be
> 0, which isn't a valid constant for a weekday) and
> adding DAYSPERWEEK
> simply can't be right, because it will always give
> results that are
> bigger than 7.

Sounds like I forgot to shake out the bugs before I
committed my last GregorianCalendar patch :(

Thanks for catching that one. I'm sure I've left a
couple of similar bugs in the GregorianCalendar code,
so I'd be glad if you could take a closer look at the
code.

danke,

dalibor topic

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com




More information about the kaffe mailing list