How to resolve the algorithm Discordian date step by step in the zkl programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Discordian date step by step in the zkl programming language
Table of Contents
Problem Statement
Convert a given date from the Gregorian calendar to the Discordian calendar.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Discordian date step by step in the zkl programming language
Source code in the zkl programming language
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);
}
foreach y,m,d in (T(T(2010,7,22), T(2012,2,28), T(2012,2,29), T(2012,3,1),
T(2010,1, 5), T(2011,5, 3))){
"%d-%02d-%02d is -->%s".fmt(y,m,d,discordianDate(y,m,d)).println();
}
You may also check:How to resolve the algorithm Align columns step by step in the Lasso programming language
You may also check:How to resolve the algorithm Boolean values step by step in the Latitude programming language
You may also check:How to resolve the algorithm Draw a clock step by step in the Ada programming language
You may also check:How to resolve the algorithm Sum digits of an integer step by step in the Draco programming language
You may also check:How to resolve the algorithm Statistics/Basic step by step in the 11l programming language