Discordian date: Difference between revisions
Content added Content deleted
m (→{{header|AppleScript}}: Tabs -> 4spaces) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 843: | Line 843: | ||
$ ./ddate # today is Jan 4, 2016 |
$ ./ddate # today is Jan 4, 2016 |
||
Prickle-Prickle, Chaos 4, YOLD 3182</pre> |
Prickle-Prickle, Chaos 4, YOLD 3182</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(this 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), |
|||
(31, 12, 2020) |
|||
}) |
|||
{ |
|||
Console.WriteLine($"{day:00}-{month:00}-{year:00} = {new DateTime(year, month, day).Discordian()}"); |
|||
} |
|||
} |
|||
}</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! |
|||
31-12-2020 = Setting Orange, day 73 of The Aftermath in the YOLD 3186.</pre> |
|||
=={{header|C++}}== |
=={{header|C++}}== |
||
Line 952: | Line 1,028: | ||
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(this 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), |
|||
(31, 12, 2020) |
|||
}) |
|||
{ |
|||
Console.WriteLine($"{day:00}-{month:00}-{year:00} = {new DateTime(year, month, day).Discordian()}"); |
|||
} |
|||
} |
|||
}</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! |
|||
31-12-2020 = Setting Orange, day 73 of The Aftermath in the YOLD 3186.</pre> |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
Line 2,461: | Line 2,461: | ||
say "$_ is " . ddate($_) for qw< 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >; |
say "$_ is " . ddate($_) for qw< 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >; |
||
</lang> |
</lang> |
||
{{out}} |
|||
<pre>2010-07-22 is Pungenday, the 57th day of Confusion in the YOLD 3176 |
|||
2012-02-28 is Prickle-Prickle, the 59th day of Chaos in the YOLD 3178 |
|||
2012-02-29 is St. Tib's Day, in the YOLD 3178 |
|||
2012-03-01 is Setting Orange, the 60th day of Chaos in the YOLD 3178 |
|||
</pre> |
|||
=={{header|Perl 6}}== |
|||
{{Works with|rakudo|2015-11-04}} |
|||
<!-- Hi Grondilu! Keep up the good work! --> |
|||
<lang perl6>my @seasons = << Chaos Discord Confusion Bureaucracy 'The Aftermath' >>; |
|||
my @days = << Sweetmorn Boomtime Pungenday Prickle-Prickle 'Setting Orange' >>; |
|||
sub ordinal ( Int $n ) { $n ~ ( $n % 100 == 11|12|13 |
|||
?? 'th' !! < th st nd rd th th th th th th >[$n % 10] ) } |
|||
sub ddate ( Str $ymd ) { |
|||
my $d = DateTime.new: "{$ymd}T00:00:00Z" or die; |
|||
my $yold = 'in the YOLD ' ~ $d.year + 1166; |
|||
my $day_of_year0 = $d.day-of-year - 1; |
|||
if $d.is-leap-year { |
|||
return "St. Tib's Day, $yold" if $d.month == 2 and $d.day == 29; |
|||
$day_of_year0-- if $day_of_year0 >= 60; # Compensate for St. Tib's Day |
|||
} |
|||
my $weekday = @days[ $day_of_year0 mod 5 ]; |
|||
my $season = @seasons[ $day_of_year0 div 73 ]; |
|||
my $season_day = ordinal( $day_of_year0 mod 73 + 1 ); |
|||
return "$weekday, the $season_day day of $season $yold"; |
|||
} |
|||
say "$_ is {.&ddate}" for < 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >; |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre>2010-07-22 is Pungenday, the 57th day of Confusion in the YOLD 3176 |
<pre>2010-07-22 is Pungenday, the 57th day of Confusion in the YOLD 3176 |
||
Line 2,888: | Line 2,851: | ||
{{Out}} |
{{Out}} |
||
<pre>Pungenday, day 47 of Confusion in the YOLD 3179</pre> |
<pre>Pungenday, day 47 of Confusion in the YOLD 3179</pre> |
||
=={{header|Raku}}== |
|||
(formerly Perl 6) |
|||
{{Works with|rakudo|2015-11-04}} |
|||
<!-- Hi Grondilu! Keep up the good work! --> |
|||
<lang perl6>my @seasons = << Chaos Discord Confusion Bureaucracy 'The Aftermath' >>; |
|||
my @days = << Sweetmorn Boomtime Pungenday Prickle-Prickle 'Setting Orange' >>; |
|||
sub ordinal ( Int $n ) { $n ~ ( $n % 100 == 11|12|13 |
|||
?? 'th' !! < th st nd rd th th th th th th >[$n % 10] ) } |
|||
sub ddate ( Str $ymd ) { |
|||
my $d = DateTime.new: "{$ymd}T00:00:00Z" or die; |
|||
my $yold = 'in the YOLD ' ~ $d.year + 1166; |
|||
my $day_of_year0 = $d.day-of-year - 1; |
|||
if $d.is-leap-year { |
|||
return "St. Tib's Day, $yold" if $d.month == 2 and $d.day == 29; |
|||
$day_of_year0-- if $day_of_year0 >= 60; # Compensate for St. Tib's Day |
|||
} |
|||
my $weekday = @days[ $day_of_year0 mod 5 ]; |
|||
my $season = @seasons[ $day_of_year0 div 73 ]; |
|||
my $season_day = ordinal( $day_of_year0 mod 73 + 1 ); |
|||
return "$weekday, the $season_day day of $season $yold"; |
|||
} |
|||
say "$_ is {.&ddate}" for < 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >; |
|||
</lang> |
|||
{{out}} |
|||
<pre>2010-07-22 is Pungenday, the 57th day of Confusion in the YOLD 3176 |
|||
2012-02-28 is Prickle-Prickle, the 59th day of Chaos in the YOLD 3178 |
|||
2012-02-29 is St. Tib's Day, in the YOLD 3178 |
|||
2012-03-01 is Setting Orange, the 60th day of Chaos in the YOLD 3178 |
|||
</pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |