Mayan calendar: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added zkl header |
→{{header|zkl}}: added code |
||
Line 615:
=={{header|zkl}}==
{{trans|Go}}
<lang zkl></lang>▼
<lang zkl>
sacred=T("Imix'","Ik'","Ak'bal","K'an","Chikchan","Kimi","Manik'","Lamat","Muluk","Ok",
"Chuwen","Eb","Ben","Hix","Men","K'ib'","Kaban","Etz'nab'","Kawak","Ajaw"),
civil=T("Pop","Wo'","Sip","Sotz'","Sek","Xul","Yaxk'in","Mol","Ch'en","Yax","Sak'","Keh",
"Mak","K'ank'in","Muwan'","Pax","K'ayab","Kumk'u","Wayeb'"),
Date=Time.Date,
// correlation dates:
Creation=T(2012, Date.December, 21), // 13.0.0.0.0, Mayan day of creation
OnePop=T(2019, Date.April, 2), // 1 Pop in 2019
;
fcn haab(date){ // (y,m,d)-->("Chum"|Int,month name)
diff:=Date.deltaDays(OnePop,date.xplode()); //--> signed int
rem:=diff%365;
if(rem<0) rem=365 + rem;
month,last := civil[(rem+1)/20], 20;
if(month==civil[-1]) last=5;
d:=rem%20 + 1;
if(d<last) return(d, month);
return("Chum",month);
}
fcn tzolkin(date){ // (y,m,d)-->(Int,String)
diff:=Date.deltaDays(Creation,date.xplode()); //--> signed int
rem:=diff % 13;
if(rem<0) rem=13 + rem;
num:=( if(rem<=9) rem + 4 else rem - 9 );
rem=diff % 20;
if(rem<=0) rem=20 + rem;
return(num, sacred[rem-1]);
}
fcn longCount(date){ // (y,m,d) --> (5 Ints)
diff:=Date.deltaDays(Creation,date.xplode()); //--> signed int
diff,baktun := diff + 13*400*360, diff/(400*360);
diff,katun := diff % (400*360), diff/(20*360);
diff,tun := diff % (20*360), diff/360;
diff,winal,kin := diff%360, diff/20, diff % 20;
return(baktun, katun, tun, winal, kin)
}
fcn lord(date){ // (y,m,d) --> String
diff:=Date.deltaDays(Creation,date.xplode()); //--> signed int
rem:=diff % 9;
if(rem<=0) rem=9 + rem;
"G%d".fmt(rem)
<lang zkl>println(" Gregorian Tzolk'in Haab' Long Lord of");
println(" Date # Name Day Month Count the Night");
println("---------- -------- ------------- -------------- ---------");
#<<<
"
1963-11-21 2004-06-19 2012-12-18 2012-12-21 2019-01-19 2019-03-27
2020-02-29 2020-03-01 2071-05-16
".split()
#<<<
.pump(Void,fcn(date){
ymd:=Date.parseDate(date);
println("%10s %2s %-9s %4s %-10s %-14s %6s".fmt(date,
tzolkin(ymd).xplode(), haab(ymd).xplode(),
longCount(ymd).concat("."),
lord(ymd)));
});</lang>
{{out}}
<pre>
Gregorian Tzolk'in Haab' Long Lord of
Date # Name Day Month Count the Night
---------- -------- ------------- -------------- ---------
1963-11-21 3 Eb Chum Keh 12.17.10.3.12 G9
2004-06-19 4 Ben 16 Sotz' 12.19.11.6.13 G7
2012-12-18 1 Kaban Chum K'ank'in 12.19.19.17.17 G6
2012-12-21 4 Ajaw 3 K'ank'in 13.0.0.0.0 G9
2019-01-19 1 Ajaw 13 Muwan' 13.0.6.3.0 G6
2019-03-27 3 Manik' Chum Wayeb' 13.0.6.6.7 G1
2020-02-29 4 Kimi 14 K'ayab 13.0.7.5.6 G7
2020-03-01 5 Manik' 15 K'ayab 13.0.7.5.7 G8
2071-05-16 1 Ok 18 Sip 13.2.19.4.10 G9
</pre>
|