Mayan Calendar

This question appears in a BIO paper. It involves conversion from one number base to another, a bit like converting pre-decimal £SD to decimal. The first thing you have to establish is the number of days in each Mayan unit.

After that you have to find the number of days since 1/1/2000. We can work out the total number of Mayan days up to 1/1/2000 because we have the Mayan equivalent: 13 20 7 16 3. Given the number of days from 1/1/2000 we can work out the date by fairly simple arithmetic. e.g. given 13/9/2001 we can add the number of days in each month to arrive at a total number of days since the beginning of Mayan time.

Code

program Project3;

uses SysUtils;

var
kin, uinal, tun, katun, baktun, days, gap:integer;
years, months, day, leapyear :integer;
yeardate, monthdate, daydate :integer;
daysleft :integer;
m :Boolean;

begin
 leapyear:=0;
 writeln('Enter baktun:');
 readln(baktun);
 writeln('Enter katun:');
 readln(katun);
 writeln('Enter tun:');
 readln(tun);
 writeln('Enter uinal:');
 readln(uinal);
 writeln('Enter kin:');
 readln(kin);
//convert Mayan values into total number of days
//uinal base = 20; tun base = 18 * uinal base (18*20=360); katun base = tun base * 20 (360*20=7,200); baktun base = katun base * 20 (7,200*20=144,000)
 days:=kin + (uinal*20) + (tun*360) + (katun*7200) + (baktun*144000);
 writeln(days); //total days in Mayan date
 readln;
 gap:=days-2018843; //gap between known start and date entered; 1/1/2000 = 2,018,843
 writeln(gap);
 readln;
 // needs developing if gap div 365 > 0 then leapyear:=1 else leapyear:=0;
 years:=gap div 365;
 yeardate:=2000+years;
 daysleft:=gap mod 365;
 //writeln(daysleft); //debug check
 readln;
 m:=false;
 if daysleft <= 31 then
 begin
  monthdate:=1;
  m:=true;
 end
 else daysleft:=daysleft-31; //january
 if (daysleft <= 28) and (not m) then
 begin
  monthdate:=2;
  m:=true;
 end
 else if not m then daysleft:=daysleft-28; //february
//mustn't subtract days in month after correct month is found
//needs further work to subtract 29 in leap year

 if (daysleft <= 31) and (not m) then
 begin
  monthdate:=3;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //march
 if (daysleft <= 30) and (not m) then
 begin
  monthdate:=4;
  m:=true;
 end
 else if not m then daysleft:=daysleft-30; //april
 if (daysleft <= 31) and (not m) then
 begin
  monthdate:=5;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //may
 if (daysleft <= 30) and (not m) then
 begin
  monthdate:=6;
  m:=true;
 end
 else if not m then daysleft:=daysleft-30; //june
 if (daysleft <= 31) and (not m) then
 begin
  monthdate:=7;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //july
 if (daysleft <= 31) and (not m) then
 begin
  monthdate:=8;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //august
 if (daysleft <= 30) and (not m) then
 begin
  monthdate:=9;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //september
 if (daysleft <= 31) and (not m) then
 begin
  monthdate:=10;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //october
 if (daysleft <= 30) and (not m) then
 begin
  monthdate:=11;
  m:=true;
 end
 else if not m then daysleft:=daysleft-30; //november
 if (daysleft <= 31) and (not m) then
 begin
  monthdate:=12;
  m:=true;
 end
 else if not m then daysleft:=daysleft-31; //december

daydate:=daysleft;
writeln(daydate:2, monthdate:3, yeardate:5);

readln;

end.

 

How about converting from a modern date to a Mayan one?

Back