Day of the week: Difference between revisions

m
→‎{{header|REXX}}: added some comments in program and section headers. -- ~~~~
(Added 4tH version)
m (→‎{{header|REXX}}: added some comments in program and section headers. -- ~~~~)
Line 1,814:
=={{header|REXX}}==
===using DATE weekday===
The extended DATE parameters (arguments 2 and 3) are only supported by the newer REXX interpreters.
<lang rexx> do year = 2008 to 2121
if date('w', year'1225', 's') == 'Sunday' then say year
end</lang>
===using DATE base===
<lang rexx> do year = 2008 to 2121
if date('b', year'1225', 's') // 7 = 6 then say year
end</lang>
'''output''' from either
<pre>2011
2016
Line 1,839 ⟶ 1,835:
2112
2118</pre>
===using DATE base===
The extended DATE parameters (arguments 2 and 3) are only supported by the newer REXX interpreters.
<lang rexx> do year = 2008 to 2121
if date('b', year'1225', 's') // 7 == 6 then say year
end</lang>
'''output''' is the same as above
<br><br>
 
===using DATE iso===
The extended DATE parameters (arguments 2 and 3) are only supported by the newer REXX interpreters.
<br><br>Language note: the DATE built-in function always returns the day-of-week in English, no matter what the native language is in effect.
<br><br>
Language note: the DATE built-in function always returns the day-of-week in English, no matter what the native language is in effect.
<lang rexx>/*REXX program displays which years December 25th falls on a Sunday. */
parse arg start finish . /*get the start and finish years.*/
Line 1,856 ⟶ 1,858:
 
say 'December 25th,' y "falls on a Sunday."
end /*y*/</lang>
/*stick a fork in it, we're done.*/</lang>
'''output''' when using the default input
<pre style="height:15ex;overflow:scroll">
Line 1,889 ⟶ 1,892:
if dow(12,25,y)==1 then say 'December 25th,' y "falls on a Sunday."
end /*y*/
exit /*stick a fork in it, we're done.*/
exit
/*─────────────────────────────────────DOW (day of week) subroutine─────*/
dow: procedure; arg m,d,y; if m<3 then do; m=m+12; y=y-1; end