Last Friday of each month: Difference between revisions

(Undo revision 231020 by Vince refiti (talk))
Line 2,829:
2012-11-30
2012-12-28
</pre>
 
=={{header|Smalltalk}}==
 
<lang Smalltalk>
Pharo Smalltalk
 
[ :yr | | firstDay firstFriday |
firstDay := Date year: yr month: 1 day: 1.
firstFriday := firstDay addDays: (6 - firstDay dayOfWeek).
(0 to: 52)
collect: [ :each | firstFriday addDays: (each * 7) ]
thenSelect: [ :each |
(((Date daysInMonth: each monthIndex forYear: yr) - each dayOfMonth) <= 6) and: [ each year = yr ] ] ]
</lang>
{{out}}
<pre>
Send value: 2012 to the above block to return an array:
(27 January 2012 24 February 2012 30 March 2012 27 April 2012 25 May 2012 29 June 2012 27 July 2012 31 August 2012 28 September 2012 26 October 2012 30 November 2012 28 December 2012)
</pre>