Discordian date: Difference between revisions
Content added Content deleted
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: | Line 1,557: | ||
If the Gregorian date is omitted or specified as an asterisk ('''*'''), the current date is used. |
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. */ |
<lang rexx>/*REXX program converts a mm/dd/yyyy Gregorian date ───► Discordian date. */ |
||
@day.1= 'Sweetness' /*define the 1st day─of─Discordian─week*/ |
|||
@day.2= 'Boomtime' /* " " 2nd " " " " */ |
|||
@day.3= 'Pungenday' /* " " 3rd " " " " */ |
|||
@day.4= 'Prickle-Prickle' /* " " 4th " " " " */ |
|||
@day.5= 'Setting Orange' /* " " 5th " " " " */ |
|||
seas.0= "St. Tib's day," |
@seas.0= "St. Tib's day," /*define the leap─day of Discordian yr.*/ |
||
seas.1= 'Chaos' |
@seas.1= 'Chaos' /* " 1st season─of─Discordian─year.*/ |
||
seas.2= 'Discord' |
@seas.2= 'Discord' /* " 2nd " " " " */ |
||
seas.3= 'Confusion' |
@seas.3= 'Confusion' /* " 3rd " " " " */ |
||
seas.4= 'Bureaucracy' |
@seas.4= 'Bureaucracy' /* " 4th " " " " */ |
||
seas.5= 'The Aftermath' |
@seas.5= 'The Aftermath' /* " 5th " " " " */ |
||
parse arg gM '/' gD "/" gY . /*get the specified Gregorian date |
parse arg gM '/' gD "/" gY . /*get the specified Gregorian date*/ |
||
if gM=='' | gM=='*' then parse value date('U') with gM '/' gD "/" gY . |
if gM=='' | gM=='*' then parse value date('U') with gM '/' gD "/" gY . |
||
gY=left(right(date(),4),4-length(Gy))gY /*adjust for |
gY=left(right(date(),4),4-length(Gy))gY /*adjust for 2─digit year or none.*/ |
||
/* [↓] day─of─year, leapyear |
/* [↓] day─of─year, leapyear adj.*/ |
||
doy=date('d',gY || right(gM,2,0)right(gD,2,0), "s") - (leapyear(gY) & gM>2) |
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 |
dW=doy//5; if dW==0 then dW=5 /*compute the Discordian weekday. */ |
||
dS=(doy-1)%73+1 |
dS=(doy-1)%73+1 /* " " " season. */ |
||
dD=doy//73; if dD==0 then dD=73 |
dD=doy//73; if dD==0 then dD=73 /*compute Discordian day─of─month.*/ |
||
dD=dD',' /*append a comma to Discordian day*/ |
|||
⚫ | |||
if ds==0 then dD= /*adjust for Discordian leap day. */ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
exit /*stick a fork in it, we're done.*/ |
exit /*stick a fork in it, we're done.*/ |
||
/*────────────────────────────────────────────────────────────────────────────*/ |
/*────────────────────────────────────────────────────────────────────────────*/ |
||
leapyear: procedure; parse arg y |
leapyear: procedure; parse arg y /*obtain four-digit Gregorian year*/ |
||
if y//4\==0 then return 0 /*Not ÷ by 4? Not a leapyear.*/ |
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> |
return y//100\==0 | y//400==0 /*apply the 100 and 400 year rule.*/</lang> |