Anonymous user
Discordian date: Difference between revisions
D entry: updated and shortened lines
(D entry: updated and shortened lines) |
|||
Line 351:
<lang d>import std.stdio, std.datetime, std.conv, std.string;
string discordianDate(in Date date) /*pure nothrow*/ {▼
static immutable
"Bureaucracy", "The Aftermath"];
immutable apostle = ["Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"];▼
static immutable
"Prickle-Prickle", "Setting Orange"];
"Zaraday", "Maladay"];
static immutable holiday = ["Chaoflux", "Discoflux", "Confuflux",
"Bureflux", "Afflux"];
▲string discordianDate(in Date date) {
▲ auto dyear = to!string(date.year + 1166);
if (isLeapYear && date.month == 2 && date.day == 29)
return "St. Tib's Day, in the YOLD " ~ dyear;
date.dayOfYear - 1 :
if (dsday == 5)
if (dsday == 50)
return holiday[doy / 73] ~ ", in the YOLD " ~ dyear;
return format("%s, day %s of %s in the YOLD %s",
dwday, dsday, dseas, dyear);
"St. Tib's Day, in the YOLD 3178");
"Setting Orange, day 60 of Chaos in the YOLD 3178");
assert(discordianDate(Date(2010,1, 5)) ==
"Mungday, in the YOLD 3176");
assert(discordianDate(Date(2011,5, 3)) ==
"Discoflux, in the YOLD 3177");
}
void main() {
▲<lang d>unittest {
▲ assert(discordianDate(Date(2010,7,22)) == "Pungenday, day 57 of Confusion in the YOLD 3176");
▲ assert(discordianDate(Date(2012,2,28)) == "Prickle-Prickle, day 59 of Chaos in the YOLD 3178");
▲ assert(discordianDate(Date(2012,2,29)) == "St. Tib's Day, in the YOLD 3178");
▲ assert(discordianDate(Date(2012,3, 1)) == "Setting Orange, day 60 of Chaos in the YOLD 3178");
▲ assert(discordianDate(Date(2010,1, 5)) == "Mungday, in the YOLD 3176");
▲ assert(discordianDate(Date(2011,5, 3)) == "Discoflux, in the YOLD 3177");
}</lang>
{{out}}
<pre>Setting Orange, day 42 of Discord in the YOLD 3178</pre>
=={{header|Euphoria}}==
|