Discordian date: Difference between revisions

(Added Rust example.)
Line 1,736:
 
=={{header|Julia}}==
{{transworks with|PythonJulia|0.6}}
 
<lang julia># v0.6.0
<lang julia>using Base.Dates
 
function discordiandate(year::Integer, month::Integer, day::Integer)
const DISCORDIANSEASONSdiscordianseasons = ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"]
const HOLIDAYSholidays = Dict(
"Chaos 5" => "Mungday",
"Chaos 50" => "Chaoflux",
"Discord 5" => "Mojoday",
"Discord 50" => "Discoflux",
"Confusion 5" => "Syaday",
"Confusion 50" => "Confuflux",
"Bureaucracy 5" => "Zaraday",
"Bureaucracy 50" => "Bureflux",
"The Aftermath 5" => "Maladay",
"The Aftermath 50" => "Afflux",)
)
today = Date(year, month, day)
isleap = isleapyear(year)
Line 1,763 ⟶ 1,762:
dy -= 1
end
ddayrst = string(DISCORDIANSEASONSdiscordianseasons[div(dy, 73) + 1], " ", rem(dy, 73)) # day
if haskey(HOLIDAYSholidays, ddayrst)
rst *= dday * " ($(HOLIDAYSholidays[ddayrst]))," YOLD# $(yearif + 1166)"holiday
else
rst = dday * ", YOLD $(year + 1166)"
end
rst *= dday * ", YOLD $(year + 1166)" # year
end
return rst
Line 1,775 ⟶ 1,773:
@show discordiandate(2017, 08, 15)
@show discordiandate(1996, 02, 29)
@show discordiandate(1996, 02, 19)</lang>
</lang>
 
{{out}}
<pre>discordiandate(2017, 8, 15) = "Bureaucracy 8, YOLD 3183"
<pre>
discordiandate(2017, 8, 15) = "Bureaucracy 8, YOLD 3183"
discordiandate(1996, 2, 29) = "St. Tib's Day, YOLD 3162"
discordiandate(1996, 2, 19) = "Chaos 50 (Chaoflux), YOLD 3162"</pre>
</pre>
 
=={{header|Kotlin}}==
Anonymous user