Discordian date: Difference between revisions

m
→‎{{header|REXX}}: added whitepace, added templates for the INPUT and OUTPUT sections.
(Added Fortran example)
m (→‎{{header|REXX}}: added whitepace, added templates for the INPUT and OUTPUT sections.)
Line 2,783:
 
parse arg gM '/' gD "/" gY . /*obtain the specified Gregorian date. */
if gM=='' | gM=="," | gM=='*' then parse value date('"U'") with gM '/' gD "/" gY .
 
gY=left( right( date(), 4), 4 - length(Gy) )gY /*adjust for two─digit year or no noneyear. */
 
/* [↓] day─of─year, leapyear adjust. */
doy= date('d', gY || right(gM, 2, 0)right(gD ,2, 0), "s") - (leapyear(gY) & gM>2)
 
dW= doy//5; if dW==0 then dW=5 if dW==0 then dW= 5 /*compute the Discordian weekday. */
dS= (doy-1) % 73+1 + 1 /* " " " season. */
dD= doy//73; if dD==0 then dD=73 if dD==0 then dD= 73 /* " " " day─of─month. */
if leapyear(gY) & gM==2 & gD==29 then ds=0 0 /*is this St. Tib's day (leapday) ? */
if ds==0 then dD= /*adjust for the Discordian leap day. */
 
say space(@day.dW',' @seas.dS dD"," gY + 1166) /*display Discordian date to terminal. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
leapyear: procedure; parse arg y /*obtain a four─digit Gregorian year. */
if y//4 \== 0 then return 0 /*Not ÷ by 4? Then not a leapyear. */
return y//100 \== 0 | y//400 ==0 0 /*apply the 100 and 400 year rules.*/</lang>
'''output''' {{out|input|text=&nbsp; when using the (various) following inputs of:}}
<pre>
2/28/2012
Line 2,813:
12/31/2100
</pre>
{{out|output|text=&nbsp; when using the above (various) inputs:}}
<pre>
Prickle-Prickle, Chaos 59, 3178