Discordian date: Difference between revisions
Content deleted Content added
→{{header|Scala}}: implementation checked, test output added |
|||
Line 1,451: | Line 1,451: | ||
{{trans|Python}}[[Category:Scala Implementations]][[Category:Scala examples needing attention]] |
{{trans|Python}}[[Category:Scala Implementations]][[Category:Scala examples needing attention]] |
||
<lang scala> val DISCORDIAN_SEASONS = Array("Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath") |
<lang scala> val DISCORDIAN_SEASONS = Array("Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath") |
||
// month from 1-12; day from 1-31 |
|||
def ddate(year: Int, month: Int, day: Int): String = { |
def ddate(year: Int, month: Int, day: Int): String = { |
||
val date = new GregorianCalendar(year, month - 1, day) |
val date = new GregorianCalendar(year, month - 1, day) |
||
Line 1,456: | Line 1,457: | ||
val isLeapYear = date.isLeapYear(year) |
val isLeapYear = date.isLeapYear(year) |
||
if (isLeapYear && month == 2 && day == 29) // |
if (isLeapYear && month == 2 && day == 29) // 2 means February |
||
"St. Tib's Day " + dyear + " YOLD" |
"St. Tib's Day " + dyear + " YOLD" |
||
else { |
else { |
||
Line 1,468: | Line 1,469: | ||
} |
} |
||
}</lang> |
}</lang> |
||
Test: |
|||
<lang scala>ddate(2010, 7, 22) // Confusion 57, 3176 YOLD |
|||
ddate(2012, 2, 28) // Chaos 59, 3178 YOLD |
|||
ddate(2012, 2, 29) // St. Tib's Day 3178 YOLD |
|||
ddate(2012, 3, 1) // Chaos 60, 3178 YOLD</lang> |
|||
=={{header|Seed7}}== |
=={{header|Seed7}}== |