[BUG?] 2.8 Week problem

Richard A. O'Keefe ok at atlas.otago.ac.nz
Tue Oct 31 00:15:04 UTC 2000


I have a copy of Squeak 2.8 with no patches running on a PowerMac.

	Week fromDate: (Date today)

displayed as "octoboer 2000, 6th week" which rather startled me.
I looked at a calendar, and sure enough, this is the 5th week.
After all, the week has started on Sunday for at least two thousand
years.  So I looked at the code, and found that

	- there is a class variable StartMonday in Week
	- the default setting for this is true (Monday).

This is a pretty sickening design.  (Thankfully the variable only
affects instance creation and not the behaviour of week objects
once created.)  Would it not be better to have
	Week (abstract class)
	 SundayWeek  >>startMonday   ^false
	 MondayWeek  >>startMonday   ^true

I can't find any method to test whether a given date is included in
a Week or Month, so I've added

	includes: aDate
	    ^self firstDate <= aDate and: [aDate <= self lastDate]

to both classes.  There are more efficient ways to do it, but this
was clear.





More information about the Squeak-dev mailing list