

Task

Convert a given date from the   Gregorian calendar   to the   Discordian calendar.




fcn discordianDate(y,m,d){
   var [const]
   seasons=T("Chaos","Discord","Confusion","Bureaucracy","The Aftermath"),
   weekday=T("Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"),
   apostle=T("Mungday","Mojoday","Syaday","Zaraday","Maladay"),
   holiday=T("Chaoflux","Discoflux","Confuflux","Bureflux","Afflux"];
 
   dYear,isLeapYear := y + 1166, Time.Date.isLeapYear(y);
   if(isLeapYear and m==2 and d==29)
      return("St. Tib's Day, in the YOLD " + dYear);
 
    doy:=Time.Date.nthDayInYear(y,m,d);
    if(isLeapYear and doy>=60) doy-=1;
    dsDay:=(if(doy%73==0) 73 else doy%73); // Season day.
    if(dsDay==5)  return(String(apostle[doy/73],", in the YOLD ",dYear));
    if(dsDay==50) return(String(holiday[doy/73],", in the YOLD ",dYear));
 
    dSeas:=seasons[(if(doy%73==0) doy-1 else doy)/73];
    dWday:=weekday[(doy - 1)%5];
    "%s, day %s of %s in the YOLD %s".fmt(dWday,dsDay,dSeas,dYear);
}