Day of the week: Difference between revisions

Content added Content deleted
(→‎{{header|CoffeeScript}}: made first example nicer, snipped second example)
Line 432: Line 432:
=={{header|CoffeeScript}}==
=={{header|CoffeeScript}}==


<lang coffeescript>for year in [2008...2121]
<lang coffeescript>
xmas = new Date year, 11, 25
december = 11 # gotta love Date APIs :)
sunday = 0
console.log "#{xmas.toDateString()} is a Sunday" if xmas.getDay() is 0</lang>
for year in [2008..2121]

xmas = new Date year, december, 25
or in a more convoluted way:
console.log year if xmas.getDay() is sunday

<lang coffeescript>for year in [2008...2121]
if (xmas = new Date year, 11, 25).getDay() is 0 then console.log xmas.getFullYear()
</lang>
</lang>


one-liner:
or yet:


<lang coffeescript>console.log year for year in [2008...2121] when new Date(year, 11, 25).getDay() is 0</lang>
<lang coffeescript>console.log year for year in [2008...2121] when new Date(year, 11, 25).getDay() is 0</lang>

<output>
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
</output>


=={{header|ColdFusion}}==
=={{header|ColdFusion}}==