Re: [Pharo-users] Week number from a date
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
https://en.wikipedia.org/wiki/Week#Week_numbering of course, not all countries have the same definition of week. furthermore, week number does not seem to be so simple.
On 12 May 2016, at 18:17, Cédrick Béler <cdrick65@gmail.com> wrote:
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
Yep :-) Davide Sven Van Caekenberghe-2 wrote
https://en.wikipedia.org/wiki/Week#Week_numbering
of course, not all countries have the same definition of week. furthermore, week number does not seem to be so simple.
On 12 May 2016, at 18:17, Cédrick Béler <
cdrick65@
> wrote:
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
-- View this message in context: http://forum.world.st/Week-number-from-a-date-tp4894486p4894535.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
What I did is wrong. It needs to add the first month days offset :)
participants (3)
-
Cédrick Béler -
Davide Varvello -
Sven Van Caekenberghe