Last Friday of each month: Difference between revisions

→‎{{header|Perl 6}}: slight twiddle
(→‎{{header|Perl 6}}: added alternative solution)
(→‎{{header|Perl 6}}: slight twiddle)
Line 507:
<lang perl6>sub MAIN (Int $year = Date.today.year) {
say ~.value.reverse.first: *.day-of-week == 5
for (classify *.month, Date.new("$year-01-01") .. Date.new("$year-12-31")).classify: *.month;
}</lang>
 
Here, <code>.classify</code> sorts the dates into one bin per month (but preserves the order in each bin). We then take the list inside each bin (<code>.value</code>) and find the last (<code>.reverse.first</code>) date which is a Friday.
 
=={{header|PHP}}==
Anonymous user