Discordian date: Difference between revisions

m
→‎{{header|REXX}}: added/changed whitespace and comments, added support for today's date.
m (→‎{{header|REXX}}: added/changed whitespace and comments, added support for today's date.)
Line 1,551:
 
=={{header|REXX}}==
<lang rexx>/*REXX program converts a mm/dd/yyyy Gregorian date ───> ───► Discordian date. */
Dday.1= 'Sweetness' /*define the 1st day─of─Discordian─week*/
/*Gregorian date may be m/d/yy ──or── m/d format. */
Dday.2= 'Boomtime' /* " " 2nd " " " " */
Dday.3= 'Pungenday' /* " " 3rd " " " " */
Dday.4= 'Prickle-Prickle' /* " " 4th " " " " */
Dday.5= 'Setting Orange' /* " " 5th " " " " */
 
dayseas.10='Sweetness' "St. Tib's day," /*define 1stthe leap─day day-of- Discordian-week yr.*/
dayseas.21= 'BoomtimeChaos' /*define 2nd day-of-Discordian-week " 1st season─of─Discordian─year.*/
dayseas.32= 'PungendayDiscord' /*define 3rd day-of-Discordian-week. " 2nd " " " " */
dayseas.43= 'Prickle-PrickleConfusion' /*define 4th day-of-Discordian-week. " 3rd " " " " */
dayseas.54='Setting Orange'Bureaucracy' /*define 5th day-of-Discordian-week. " 4th " " " " */
seas.5= 'The Aftermath' /*define " 5th season-of-Discordian-year. " " " " */
 
seas.0="St.parse arg gM Tib's/' gD day,"/" gY . /*defineget the leap-dayspecified ofGregorian Discordian yrdate. */
seas.1if gM=='Chaos' | gM=='*' then parse value date('U') with gM '/' gD "/*define" 1st season-of-Discordian-yeargY .*/
seas.2='Discord' /*define 2nd season-of-Discordian-year.*/
seas.3='Confusion' /*define 3rd season-of-Discordian-year.*/
seas.4='Bureaucracy' /*define 4th season-of-Discordian-year.*/
seas.5='The Aftermath' /*define 5th season-of-Discordian-year.*/
 
gY=left(right(date(),4),4-length(Gy))gY /*adjust for a 2-dig2─digit yryear or none.*/
parse arg gM '/' gD "/" gY . /*get the date specified. */
 
gY=left(right(date(),4),4-length(Gy))gY /*adjust for a 2-dig yr or none*/
/*below:get day-of-year[↓] day─of─year,adj LeapYleapyear 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 /*compute the Discordian weekday.*/
dSdW=(doy-1)%73+1 //5; if dW==0 then dW=5 /*compute the Discordian seasonweekday. */
dS=(doy-1)%73+1 /* " " season. */
dD=doy//73;if dD==0 then dD=73; dD=dD',' /*Discordian day-of-month.*/
ifdD=doy//73; leapyear(gY) &if gMdD==020 & gD==29 then dodD=73; dD=dD','; ds=0; end /*St.the Tib's?Discordian day─of─month.*/
 
say space(day.dW',' seas.dS dD gY+1166) /*show and tell Discordian date*/
exit if leapyear(gY) & gM==02 & gD==29 then do; dD=; ds=0; end /*stickSt. a fork in it, weTib'res? done.*/
 
/*─────────────────────────────────────LEAPYEAR subroutine──────────────*/
say space(dayDday.dW',' seas.dS dD gY+1166) /*showdisplay and tellthe Discordian date.*/
leapyear: procedure; arg y
ifexit y//4\==0 then return 0 /* not by 4? Not /*stick a leapyearfork in it, we're done.*/
/*────────────────────────────────────────────────────────────────────────────*/
return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */</lang>
leapyear: procedure; parse arg y /*obtain four-digit Gregorian year*/
{{Out}} when using the inputs of:
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>
'''output''' &nbsp; when using the (various) following inputs of:
<pre>
2/28/2012