Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!munnari.oz.au!bruce!goanna!pnm From: pnm@goanna.cs.rmit.oz.au (Paul Menon) Newsgroups: comp.lang.smalltalk Subject: PP ST R4 - Date dayOfWeek: neverOnASunday!! Keywords: burg Message-ID: <4992@goanna.cs.rmit.oz.au> Date: 18 Mar 91 09:35:17 GMT Article-I.D.: goanna.4992 Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 33 hi, A nasty with PPOWST R4 - Beware of converting #Sunday into a day of week index. It gives you 0, not 7. Maybe because Sunday isn't a weekday? :-) And we *should* be working on Saturday, right? Here's Date's method for dayOfWeek (class protocol: general inquiries).. --------------------------- dayOfWeek: dayName "Answer the index in a week, 1 - 7, of the day named dayName. Provide an error notification if no such day exists." 1 to: 7 do: [:index | (WeekDayNames at: index) = dayName ifTrue: [^index \\ 7]]. self error: dayName asString , ' is not a day of the week' -------------------------- The "^index \\ 7" above is the trap. 7 mod 7 is 0, not 7. Should I change this method? Once again, apologies if this has already been thrashed... Paul Menon, Dept of Computer Science, Royal Melbourne Institute of Technology, 124 Latrobe Street, Melbourne 3001, Victoria, Australia. pnm@goanna.cs.rmit.oz.au PH: +61 3 660 3209