Discordian date: Difference between revisions
Content added Content deleted
(Discordian date en FreeBASIC) |
(Added Wren) |
||
Line 4,001: | Line 4,001: | ||
St. Tib's Day, 3178 YOLD |
St. Tib's Day, 3178 YOLD |
||
Chaos 60, 3178 YOLD |
Chaos 60, 3178 YOLD |
||
</pre> |
|||
=={{header|Wren}}== |
|||
{{trans|C#}} |
|||
{{libheader|Wren-date}} |
|||
{{libheader|Wren-fmt}} |
|||
<lang ecmascript>import "/date" for Date |
|||
import "/fmt" for Fmt |
|||
var seasons = ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"] |
|||
var weekdays = ["Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"] |
|||
var apostles = ["Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"] |
|||
var holidays = ["Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"] |
|||
var discordian = Fn.new { |date| |
|||
var y = date.year |
|||
var yold = " in the YOLD %(y + 1166)." |
|||
var doy = date.dayOfYear |
|||
if (Date.isLeapYear(y)) { |
|||
if (doy == 60) return "St. Tib's Day" + yold |
|||
if (doy > 60) doy = doy - 1 |
|||
} |
|||
doy = doy - 1 |
|||
var seasonDay = doy % 73 + 1 |
|||
var seasonNr = (doy/73).floor |
|||
var weekdayNr = doy % 5 |
|||
var holyday = "" |
|||
if (seasonDay == 5) holyday = " Celebrate %(apostles[seasonNr])!" |
|||
if (seasonDay == 50) holyday = " Celebrate %(holidays[seasonNr])!" |
|||
var season = seasons[seasonNr] |
|||
var dow = weekdays[weekdayNr] |
|||
return Fmt.swrite("$s, day $s of $s$s$s", dow, seasonDay, season, yold, holyday) |
|||
} |
|||
var dates = [ |
|||
"2010-01-01", |
|||
"2010-01-05", |
|||
"2011-02-19", |
|||
"2012-02-28", |
|||
"2012-02-29", |
|||
"2012-03-01", |
|||
"2013-03-19", |
|||
"2014-05-03", |
|||
"2015-05-31", |
|||
"2016-06-22", |
|||
"2016-07-15", |
|||
"2017-08-12", |
|||
"2018-09-19", |
|||
"2018-09-26", |
|||
"2019-10-24", |
|||
"2020-12-08", |
|||
"2020-12-31" |
|||
] |
|||
for (date in dates) { |
|||
var dt = Date.parse(date) |
|||
System.print("%(date) = %(discordian.call(dt))") |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
2010-01-01 = Sweetmorn, day 1 of Chaos in the YOLD 3176. |
|||
2010-01-05 = Setting Orange, day 5 of Chaos in the YOLD 3176. Celebrate Mungday! |
|||
2011-02-19 = Setting Orange, day 50 of Chaos in the YOLD 3177. Celebrate Chaoflux! |
|||
2012-02-28 = Prickle-Prickle, day 59 of Chaos in the YOLD 3178. |
|||
2012-02-29 = St. Tib's Day in the YOLD 3178. |
|||
2012-03-01 = Setting Orange, day 60 of Chaos in the YOLD 3178. |
|||
2013-03-19 = Pungenday, day 5 of Discord in the YOLD 3179. Celebrate Mojoday! |
|||
2014-05-03 = Pungenday, day 50 of Discord in the YOLD 3180. Celebrate Discoflux! |
|||
2015-05-31 = Sweetmorn, day 5 of Confusion in the YOLD 3181. Celebrate Syaday! |
|||
2016-06-22 = Pungenday, day 27 of Confusion in the YOLD 3182. |
|||
2016-07-15 = Sweetmorn, day 50 of Confusion in the YOLD 3182. Celebrate Confuflux! |
|||
2017-08-12 = Prickle-Prickle, day 5 of Bureaucracy in the YOLD 3183. Celebrate Zaraday! |
|||
2018-09-19 = Boomtime, day 43 of Bureaucracy in the YOLD 3184. |
|||
2018-09-26 = Prickle-Prickle, day 50 of Bureaucracy in the YOLD 3184. Celebrate Bureflux! |
|||
2019-10-24 = Boomtime, day 5 of The Aftermath in the YOLD 3185. Celebrate Maladay! |
|||
2020-12-08 = Boomtime, day 50 of The Aftermath in the YOLD 3186. Celebrate Afflux! |
|||
2020-12-31 = Setting Orange, day 73 of The Aftermath in the YOLD 3186. |
|||
</pre> |
</pre> |
||