Anonymous user
Discordian date: Difference between revisions
m
→{{header|REXX}}: split some lines, aligned some comments, allowed for malformed MM and DD.
m (→{{header|REXX}}: added comments to the REXX section header.) |
m (→{{header|REXX}}: split some lines, aligned some comments, allowed for malformed MM and DD.) |
||
Line 1,557:
If the Gregorian date is omitted or specified as an asterisk ('''*'''), the current date is used.
<lang rexx>/*REXX program converts a mm/dd/yyyy Gregorian date ───► Discordian date. */
@seas.0= "St. Tib's day,"
@seas.1= 'Chaos'
@seas.2= 'Discord'
@seas.3= 'Confusion'
@seas.4= 'Bureaucracy'
@seas.5= 'The Aftermath'
parse arg gM '/' gD "/" gY . /*get the specified Gregorian date
if gM=='' | gM=='*' then parse value date('U') with gM '/' gD "/" gY .
gY=left(right(date(),4),4-length(Gy))gY /*adjust for
/* [↓] day─of─year, leapyear
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
dS=(doy-1)%73+1
dD=doy//73; if dD==0 then dD=73
dD=dD',' /*append a comma to Discordian day*/
if ds==0 then dD= /*adjust for Discordian leap day. */
▲if leapyear(gY) & gM==02 & gD==29 then do; dD=; ds=0; end /*St. Tib's? */
▲say space(Dday.dW',' seas.dS dD gY+1166) /*display the Discordian date.*/
exit /*stick a fork in it, we're done.*/
/*────────────────────────────────────────────────────────────────────────────*/
leapyear: procedure; parse arg y
if y//4\==0 then return 0 /*Not ÷ by 4? Not a leapyear.*/
return y//100\==0 | y//400==0 /*apply the 100 and 400 year rule.*/</lang>
|