Long year: Difference between revisions

Content added Content deleted
(Add Cowgol)
(→‎{{header|REXX}}: refurbished)
Line 2,405:
 
=={{header|REXX}}==
<syntaxhighlight lang="rexx">/*REXX program determines ifIf a (calendar) year is a SHORTshort or LONGlong year (52 or 53 weeks).*/
parse/* arg LO HI . /*obtain optional args. (52 or 53 weeks). */
exit 0 Parse Arg lo hi . /*stick a fork in it, we'reobtain alloptional doneargs. */
if LO=='' | LO=="," | LO=='*' then LO= left( date('S'), 4) /*Not given? Use default.*/
current=left(date('S'),4)
if HI=='' | HI=="," then HI= LO /* " " " " */
ifIf LOlo=='' | LOlo=="," | LOlo=='*' Then then LOlo= left( date('S'), 4) current /*Not given? Use default.*/
if HI=='*' then HI= left( date('S'), 4) /*an asterisk ≡ current yr*/
ifIf HIhi=='' | HIhi=="," Then then HIhi= LO lo /* " " " " */
ifIf HIhi=='*' Then then HIhi= left( date('S'), 4) current /*an asterisk: current yr*/
 
Do do jyr=LO to HI lo To hi /* process single yr or range of years.*/
saySay ' year ' yr j "' is a " right( word('short long', weeks(j)-51),5) " year"
right(word('short long',is_long(yr)+1),5) ' year'
end /*j*/
End
exit 0 /*stick a fork in it, we're all done. */
Exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*----------------------------------------------------------------------*/
pWeek: parse arg #; return (# + # % 4 - # % 100 + # % 400) // 7
wd_1231:
weeks: parse arg y; if pWeek(y)==4 | pWeek(y-1)==3 then return 53; return 52</syntaxhighlight>
/*************************************************************************
* returns the day of the week of 31 December year
*************************************************************************/
Parse Arg year
Return (year+year%4-year%100+year%400)//7
 
is_long:
Parse Arg year
Return wd_1231(year)==4 |, /* year ends in a Thursday */
wd_1231(year-1)==3 /* or previous year ends in a Wednesday */</syntaxhighlight>
{{out|output|text=&nbsp; when using the inputs of: &nbsp; &nbsp; <tt> 1990 &nbsp; 2030 </tt>}}