Anonymous user
Day of the week: Difference between revisions
m
→{{header|REXX}}: fixed up an ill-formatted REXX comment.
m (→old school DOW: removed OVERFLOW from a PRE html tag.) |
m (→{{header|REXX}}: fixed up an ill-formatted REXX comment.) |
||
Line 2,085:
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.
<lang rexx>/*REXX program displays which years December 25th falls on a Sunday.
parse arg start finish . /*get the start and finish years.*/
if start=='' then start=2008
if finish=='' then finish=2121
do y=start to finish
if date('Weekday',y"-12-25",'ISO')\=='Sunday' then iterate
/* if date('w' ,y"-12-25",'i' )
/* option yyyy-mm-dd fmt */
say 'December 25th,' y "falls on a
end /*y*/
/*stick a fork in it, we're done.*/</lang>
Line 2,122:
===old school DOW ===
This DOW (day-of-week) version will work with any version of a REXX interpreter.
<lang rexx>/*REXX program (old school) displays which years 12/25 falls on a Sunday*
parse arg start finish . /*get the start and finish years.*/
if start=='' then start=2008
if finish=='' then finish=2121
do y=start to finish /*process the years specified. *
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.*/
/*──────────────────────────────────DOW (day of week) subroutine────────*/
dow: procedure; parse arg m,d,y;
yL=left(y,2); yr=right(y,2); w=(d + (m+1)*26%10+yr+yr%4+yL%4+5*yL) // 7
if w==0 then w=7; return w
{{out}} using the default input
<pre style="height:15ex">
|