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. */ |
||
gY=left(right(date(),4),4-length(Gy))gY /*adjust for a 2-dig yr or none*/ |
|||
/*below:get day-of-year,adj LeapY*/ |
|||
⚫ | |||
gD=right(gD,2,0) /*ensure two-digit dayo-of-month.*/ |
|||
⚫ | |||
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=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 |
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. */ |