Find the last Sunday of each month: Difference between revisions

(→‎{{header|Ruby}}: Calculate, not loop until sunday.)
Line 880:
26}, {2013, 6, 30}, {2013, 7, 28}, {2013, 8, 25}, {2013, 9,
29}, {2013, 10, 27}, {2013, 11, 24}, {2013, 12, 29}}</pre>
 
=={{header|Oforth}}==
<lang Oforth>func: lastSunday(y)
{
| m |
Date.JANUARY Date.DECEMBER for: m [
Date newDate(y, m, Date.DaysInMonth(y, m))
while(dup dayOfWeek Date.SUNDAY <>) [ addDays(-1) ]
println
]
}
</lang>
{{out}}
<pre>
2013-01-27 00:00:00,000
2013-02-24 00:00:00,000
2013-03-31 00:00:00,000
2013-04-28 00:00:00,000
2013-05-26 00:00:00,000
2013-06-30 00:00:00,000
2013-07-28 00:00:00,000
2013-08-25 00:00:00,000
2013-09-29 00:00:00,000
2013-10-27 00:00:00,000
2013-11-24 00:00:00,000
2013-12-29 00:00:00,000
</pre>
 
=={{header|Nim}}==
1,015

edits