Discordian date: Difference between revisions
Content added Content deleted
m (Forgot to check the boundarys between the seasons, had an off-by-one type error, fixed.) |
(Added Julia language) |
||
Line 1,734: | Line 1,734: | ||
@add(@time("year"),3066)) |
@add(@time("year"),3066)) |
||
)),".")</lang> |
)),".")</lang> |
||
=={{header|Julia}}== |
|||
{{trans|Python}} |
|||
<lang julia># v0.6.0 |
|||
using Dates |
|||
function discordiandate(year, month, day) |
|||
const DISCORDIANSEASONS = ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"] |
|||
const HOLIDAYS = 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) |
|||
if isleap && month == 2 && day == 29 |
|||
rst = "St. Tib's Day, YOLD " * string(year + 1166) |
|||
else |
|||
dy = dayofyear(today) |
|||
if isleap && dy >= 60 |
|||
dy -= 1 |
|||
end |
|||
dday = string(DISCORDIANSEASONS[div(dy, 73) + 1], " ", rem(dy, 73)) |
|||
if haskey(HOLIDAYS, dday) |
|||
rst = dday * " ($(HOLIDAYS[dday])), YOLD $(year + 1166)" |
|||
else |
|||
rst = dday * ", YOLD $(year + 1166)" |
|||
end |
|||
end |
|||
return rst |
|||
end |
|||
@show discordiandate(2017, 08, 15) |
|||
@show discordiandate(1996, 02, 29) |
|||
@show discordiandate(1996, 02, 19) |
|||
</lang> |
|||
{{out}} |
|||
<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> |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |