Find the last Sunday of each month: Difference between revisions

Content added Content deleted
(→‎{{header|Ruby}}: Calculate, not loop until sunday.)
Line 1,232: Line 1,232:
(1..12).map do |month|
(1..12).map do |month|
d = Date.new(year, month, -1) # -1 means "last".
d = Date.new(year, month, -1) # -1 means "last".
d -= 1 until d.sunday?
d - d.wday
d
end
end
end
end
Line 1,255: Line 1,254:
</pre>
</pre>
Results before the year 1581 may differ from other languages - the Date library takes the Julian reform into account.
Results before the year 1581 may differ from other languages - the Date library takes the Julian reform into account.

=={{header|Scala}}==
=={{header|Scala}}==
<lang Scala>object FindTheLastSundayOfEachMonth extends App {
<lang Scala>object FindTheLastSundayOfEachMonth extends App {