[Pharo-users] Week number from a date

Cédrick Béler cdrick65 at gmail.com
Fri May 13 04:40:59 EDT 2016

Yes I agree. We may have a preference to set the week day start ( fistDayOfWeek ?) .

After that we could agree on the fact the first week is the first complete week (otherwise it can be a preference).
Then we need to find the first day index of the first fistDayOfWeek. (Date year: self year day: 1) weekdayIndex -> gives the index according to the preference (for now Sunday -> 1)

Then it’s quite straightforward to get the week number.
Just have to check if the current date is in the last week of the previous year (returns 52 or 53). I did something but not sure yet (but no preference).
There are been some works on time representation (Chronos if I remember well ? but cannot load in Pharo 5, depends on OSProcess).
An interesting read [1].
ps: http://stephane.ducasse.free.fr/Teaching/CoursAnnecy/0506-M1-COO/A%20New%20Object-Oriented%20Model%20of%20the%20Gregorian%20Calendar.pdf

Interesting to know. But I see this already seems hard coded...

Date nameOfDay: 1 "--> #Sunday"

Timespan subclass: #Date
poolDictionaries: 'ChronologyConstants'

ChronologyConstants class >> initialize
DayNames := #(Sunday Monday Tuesday Wednesday Thursday Friday Saturday).

Also seems to have changed at some point, with the historical
nameOfDay recorded in the Terse Guide [1] circa 2010 shown to be
different. Perhaps this is something we should make a regional
preference. Was there any ongoing works on other regional
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160513/c1a5884e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 32327 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160513/c1a5884e/attachment.png>

More information about the Pharo-users mailing list