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. */
Dday@day.1= 'Sweetness' /*define the 1st day─of─Discordian─week*/
Dday@day.2= 'Boomtime' /* " " 2nd " " " " */
Dday@day.3= 'Pungenday' /* " " 3rd " " " " */
Dday@day.4= 'Prickle-Prickle' /* " " 4th " " " " */
Dday@day.5= 'Setting Orange' /* " " 5th " " " " */
 
@seas.0= "St. Tib's day," /*define the leap─day of Discordian yr.*/
@seas.1= 'Chaos' /* " 1st season─of─Discordian─year.*/
@seas.2= 'Discord' /* " 2nd " " " " */
@seas.3= 'Confusion' /* " 3rd " " " " */
@seas.4= 'Bureaucracy' /* " 4th " " " " */
@seas.5= 'The Aftermath' /* " 5th " " " " */
 
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 a 2─digit year or none.*/
 
/* [↓] day─of─year, leapyear adjustadj.*/
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 /*compute the Discordian weekday. */
dS=(doy-1)%73+1 /* " " " season. */
dD=doy//73; if dD==0 then dD=73; dD=dD',' /*thecompute Discordian day─of─month.*/
dD=dD',' /*append a comma to Discordian day*/
if leapyear(gY) & gM==022 & gD==29 then do; dD=; ds=0; end /*is this /*St. Tib's? day (leapday)?*/
if ds==0 then dD= /*adjust for Discordian leap day. */
 
say space(Dday@day.dW',' @seas.dS dD gY+1166) /*display the Discordian date. */
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 /*obtain four-digit Gregorian year*/
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>