[Pharo-users] Week number from a date

Cédrick Béler cdrick65 at gmail.com
Thu May 12 12:17:18 EDT 2016


Not sure it exists (I didn’t find it but it may exists)… so I did a quick try to code a new method in the class Week.
There is already index but this method returns the index of the current month.
I did something like below (not tested much):
Week>>yearIndex
^ (self dayOfYear / 7 + 1) asInteger

==== DateAndTime now asWeek yearIndex returns 19
Maybe it would be better to create an equivalent method (weekYearIndex) in Date (or eventually Timespan).
hth,
Cédrik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160512/aeec3f6f/attachment.html>


More information about the Pharo-users mailing list