Discordian date: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: adjusted scroll window height.)
m (→‎{{header|REXX}}: added support for 2-digit year.)
Line 173: Line 173:


parse arg gM '/' gD "/" gY . /*get the date specified. */
parse arg gM '/' gD "/" gY . /*get the date specified. */
if gY=='' then gY=left(date('S',4)) /*if year omitted, assume this yr*/
gY=left(right(date(),4),4-length(Gy))gY /*adjust for a 2-dig yr or none*/
gM=right(gM,2,0) /*ensure two-digit month of year.*/
/*below:get day-of-year,adj LeapY*/
doy=date('d',gY||right(gM,2,0)right(gD,2,0),"s")-(leapyear(gY) & gM>2)
gD=right(gD,2,0) /*ensure two-digit dayo-of-month.*/
doy=date('D',gY||gM||gD,"s")-(leapyear(gY) & gM>2) /*get day-of-year.*/
say 'day of year='doy
dY=gY+1166 /*compute the Discordian year. */
dW=doy//5;if dW==0 then dW=5 /*compute the Discordian weekday.*/
dW=doy//5;if dW==0 then dW=5 /*compute the Discordian weekday.*/
dS=(doy-1)%73+1 /*compute the Discordian season. */
dS=(doy-1)%73+1 /*compute the Discordian season. */
dD=doy//73;if dD==0 then dD=73; dD=dD',' /*Discordian day-of-month.*/
dD=doy//73;if dD==0 then dD=73; dD=dD',' /*Discordian day-of-month.*/
if leapyear(gY) & gM==02 & gD==29 then do; dD=''; ds=0; end /*St. Tib's?*/
if leapyear(gY) & gM==02 & gD==29 then do; dD=''; ds=0; end /*St. Tib's?*/
say space(day.dW',' seas.dS dD dY) /*show and tell Discordian date. */
say space(day.dW',' seas.dS dD gY+1166) /*show and tell Discordian date*/
exit
exit



/*─────────────────────────────────────LEAPYEAR subroutine──────────────*/
/*─────────────────────────────────────LEAPYEAR subroutine──────────────*/
leapyear: procedure; arg y
leapyear: procedure; arg y
if length(y)==2 then y=left(right(date(),4),2)y /*adjust for YY 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 100 and 400 year rule. */
return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */