Hey folks.
I'm currently working on a domain specific language (embedded in Scala) for describing calendars, querying them, creating dates and converting between calendars. Domain specific languages (DSLs) are used for communication between programmers and experts of certain domains. Instead of implementing a single program, you basically create a simple language so the experts can either configure the program themselves or at least understand your configuration.
This is what the Tranquility Calendar would look like.
I'm currently working on a domain specific language (embedded in Scala) for describing calendars, querying them, creating dates and converting between calendars. Domain specific languages (DSLs) are used for communication between programmers and experts of certain domains. Instead of implementing a single program, you basically create a simple language so the experts can either configure the program themselves or at least understand your configuration.
This is what the Tranquility Calendar would look like.
Quote:object TranquilityCalendar {
import CommonDays._
import PlanetaryWeek._
import MonthsAndYears.{year,years,y,Y}
val month = Cycle from weeks(4) named "month"
def months = month
def m = num(month)(2)
def M = nam(month)("default")
val firstHalfYear = months("Archimedes", "Brahe", "Copernicus", "Darwin", "Einstein", "Faraday", "Galileo", "Hippocrates" )
val aldrin = day named "Aldrin Day"
val secondHalfYear = months( "Imhotep", "Jung", "Kepler", "Lavoisier", "Mendel" )
val armstrong = day named "Armstrong Day"
val standardYear = firstHalfYear + secondHalfYear + armstrong as year
val leapYear = firstHalfYear + aldrin + secondHalfYear + armstrong as year
val tranquilityEra = Era given
(y => WesternCalendar.westernEra.getChild(y + 3) == WesternCalendar.leapYear) have leapYear
tranquilityEra rest standardYear
tranquilityEra setEraNames ( x => Map( "default" -> (if (x>=0) x + " AT" else x + " BT") ) )
val tranquilityCalendar = Calendar(tranquilityEra) setTimeStampZero (year/1 & month/6 & day/25)
tranquilityCalendar addFormat "default" -> df"$y-$m-$d-$h:$min:$s"
}