Discordian date: Difference between revisions

Content added Content deleted
(→‎{{header|PL/M}}: Get the Gregorian date from the command line)
(Added Action!)
Line 476: Line 476:
C:\>ddate 01/05/2005
C:\>ddate 01/05/2005
Setting Orange, day 5 of Chaos in the YOLD 3171: celebrate Mungday!
Setting Orange, day 5 of Chaos in the YOLD 3171: celebrate Mungday!
</pre>

=={{header|Action!}}==
{{Trans|MAD}}...via PL/M
<syntaxhighlight lang="action!">
;;; Discordian date calculation - translation of MAD (via PL/M)

;;; returns the next number from line, the terminator is ignored
;;; pos holds the position in line and is updated to the
;;; position of the character following the trailing
;;; delimiter - if there is one
;;; pos should be set to 1 on rhe first call
INT FUNC getNumber( CHAR ARRAY line, CARD POINTER pos )
CARD value, linePos

linePos = pos^
value = 0
; skip spaces
WHILE linePos <= line(0) AND line(linePos) = ' DO linePos ==+ 1 OD
; get the number
WHILE linePos <= line(0) AND line(linePos) >= '0 AND line(linePos) <= '9
DO
value ==* 10
value ==+ (line(linePos) - '0)
linePos ==+ 1
OD
pos^ = linePos + 1
RETURN(value)

;;; get a Gregorian date and output it as a Discordian date
PROC Main()

DEFINE STRING_POINTER = "CARD"

CARD gMonth, gDay, gYear, gPos
CARD yrDay, season, day, wkDay
CHAR ARRAY gLine(256)
STRING_POINTER ARRAY holy5(5), holy50(5), disday(5), disssn(5)
INT ARRAY mlengt(13) = [ 0 0 31 59 90 120
151 181 212 243 273 304 334
]
holy5 (0) = "MUNG" holy5 (1) = "MOJO" holy5 (2) = "SYA"
holy5 (3) = "ZARA" holy5 (4) = "MALA"
holy50(0) = "CHAO" holy50(1) = "DISCO" holy50(2) = "CONFU"
holy50(3) = "BURE" holy50(4) = "AF"
disday(0) = "SWEETMORN" disday(1) = "BOOMTIME"
disday(2) = "PUNGENDAY" disday(3) = "PRICKLE-PRICKLE"
disday(4) = "SETTING ORANGE"
disssn(0) = "CHAOS" disssn(1) = "DISCORD" disssn(2) = "CONFUSION"
disssn(3) = "BUREAUCRACY" disssn(4) = "THE AFTERMATH"

; get the Gregorian date from the keyboard, NB: no validation
Print("Gregorian date (MM/DD/YYYY)> ")
InputS(gLine)
gPos = 1
gMonth = getNumber(gLine, @gPos)
gDay = getNumber(gLine, @gPos)
gYear = getNumber(gLine, @gPos)

; convert to Discordian
IF gMonth = 2 AND gDay = 29 THEN
Print("SAINT TIB'S DAY IN THE Y.O.L.D. ")PrintC(gYear+1166)
ELSE
yrDay = mlengt(gMonth)+gDay
season = yrDay/73
day = yrDay-season*73
wkDay = (yrDay-1) MOD 5
Print(disday(wkDay) )Print(", DAY ")PrintC(day)Print(" OF ")
Print(disssn(season))Print(" IN THE Y.O.L.D ")PrintC(gYear+1166)
IF day = 5 THEN
PutE()
Print("CELEBRATE ")Print(holy5(season))Print("DAY")
ELSEIF day = 50 THEN
PutE()
Print("CELEBRATE ")Print(holy50(season))Print("FLUX")
FI
FI
PutE()

RETURN
</syntaxhighlight>
{{out}}
<pre>
Gregorian date (MM/DD/YYYY)> 4/1/2023
SWEETMORN, DAY 18 OF DISCORD IN THE Y.O.L.D 3189
</pre>
</pre>