Discordian date: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added whitepace, added templates for the INPUT and OUTPUT sections.) |
(Added C#) |
||
Line 899: | Line 899: | ||
Pungenday, Bureaucracy 19th, Year of Our Lady of Discord 3182 |
Pungenday, Bureaucracy 19th, Year of Our Lady of Discord 3182 |
||
</pre> |
</pre> |
||
=={{header|C sharp}}== |
|||
<lang csharp>using System; |
|||
public static class DiscordianDate |
|||
{ |
|||
static readonly string[] seasons = { "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath" }; |
|||
static readonly string[] weekdays = { "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange" }; |
|||
static readonly string[] apostles = { "Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay" }; |
|||
static readonly string[] holidays = { "Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux" }; |
|||
public static string Discordian(DateTime date) { |
|||
string yold = $" in the YOLD {date.Year + 1166}."; |
|||
int dayOfYear = date.DayOfYear; |
|||
if (DateTime.IsLeapYear(date.Year)) { |
|||
if (dayOfYear == 60) return "St. Tib's day" + yold; |
|||
else if (dayOfYear > 60) dayOfYear--; |
|||
} |
|||
dayOfYear--; |
|||
int seasonDay = dayOfYear % 73 + 1; |
|||
int seasonNr = dayOfYear / 73; |
|||
int weekdayNr = dayOfYear % 5; |
|||
string holyday = ""; |
|||
if (seasonDay == 5) holyday = $" Celebrate {apostles[seasonNr]}!"; |
|||
else if (seasonDay == 50) holyday = $" Celebrate {holidays[seasonNr]}!"; |
|||
return $"{weekdays[weekdayNr]}, day {seasonDay} of {seasons[seasonNr]}{yold}{holyday}"; |
|||
} |
|||
public static void Main() { |
|||
foreach (var (day, month, year) in new [] { |
|||
(1, 1, 2010), |
|||
(5, 1, 2010), |
|||
(19, 2, 2011), |
|||
(28, 2, 2012), |
|||
(29, 2, 2012), |
|||
(1, 3, 2012), |
|||
(19, 3, 2013), |
|||
(3, 5, 2014), |
|||
(31, 5, 2015), |
|||
(22, 6, 2016), |
|||
(15, 7, 2016), |
|||
(12, 8, 2017), |
|||
(19, 9, 2018), |
|||
(26, 9, 2018), |
|||
(24, 10, 2019), |
|||
(8, 12, 2020) |
|||
}) |
|||
{ |
|||
Console.WriteLine($"{day:00}-{month:00}-{year:00} = {Discordian(new DateTime(year, month, day))}"); |
|||
} |
|||
} |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
01-01-2010 = Sweetmorn, day 1 of Chaos in the YOLD 3176. |
|||
05-01-2010 = Setting Orange, day 5 of Chaos in the YOLD 3176. Celebrate Mungday! |
|||
19-02-2011 = Setting Orange, day 50 of Chaos in the YOLD 3177. Celebrate Chaoflux! |
|||
28-02-2012 = Prickle-Prickle, day 59 of Chaos in the YOLD 3178. |
|||
29-02-2012 = St. Tib's day in the YOLD 3178. |
|||
01-03-2012 = Setting Orange, day 60 of Chaos in the YOLD 3178. |
|||
19-03-2013 = Pungenday, day 5 of Discord in the YOLD 3179. Celebrate Mojoday! |
|||
03-05-2014 = Pungenday, day 50 of Discord in the YOLD 3180. Celebrate Discoflux! |
|||
31-05-2015 = Sweetmorn, day 5 of Confusion in the YOLD 3181. Celebrate Syaday! |
|||
22-06-2016 = Pungenday, day 27 of Confusion in the YOLD 3182. |
|||
15-07-2016 = Sweetmorn, day 50 of Confusion in the YOLD 3182. Celebrate Confuflux! |
|||
12-08-2017 = Prickle-Prickle, day 5 of Bureaucracy in the YOLD 3183. Celebrate Zaraday! |
|||
19-09-2018 = Boomtime, day 43 of Bureaucracy in the YOLD 3184. |
|||
26-09-2018 = Prickle-Prickle, day 50 of Bureaucracy in the YOLD 3184. Celebrate Bureflux! |
|||
24-10-2019 = Boomtime, day 5 of The Aftermath in the YOLD 3185. Celebrate Maladay! |
|||
08-12-2020 = Boomtime, day 50 of The Aftermath in the YOLD 3186. Celebrate Afflux!</pre> |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |