Mayan calendar: Difference between revisions
m
syntax highlighting fixup automation
(Python 3.6 code for mayan calendar solving task) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 213:
2020-03-01
=={{header|Fortran}}==
<syntaxhighlight lang="fortran">
PROGRAM MAYA_DRIVER
IMPLICIT NONE
Line 375:
END SUBROUTINE maya_time
</syntaxhighlight>
{{out}}
<pre>
Line 390:
=={{header|Go}}==
<
import (
Line 491:
fmt.Printf("%s %2d %-8s %4s %-9s %-14s %s\n", dt, n, s, d, m, lc, l)
}
}</
{{out}}
Line 511:
Implementation:
<
NB. 1794214= (0 20 18 20 20#.13 0 0 0 0)-todayno 2012 12 21
Line 535:
round=: [:;:inv tsolkin;haab;'G',&":1+9|]
gmt=: >@(fmtDate;round;longcount)@todayno</
J's <tt>todayno</tt> counts days from January 1, 1800. And, each of these date formatting routines expects a number generated by todayno, with hard coded offsets, if necessary, to make this work. (The lord of night number uses an offset of zero, in this context.)
Line 542:
Task examples:
<
June 19, 2004
4 Ben 16 Sotz’ G7
Line 575:
March 1, 2019
3 Imix’ 14 K’ayab G2
13.0.5.13.1</
=={{header|Julia}}==
{{trans|Go}}
<
const Tzolk´in = [
Line 632:
rpad(haab(date), 15), nightlord(date))
end
</
<pre>
Gregorian Long Count Tzolk´in Haab´ Nightlord
Line 649:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
"Ak\[CloseCurlyQuote]bal", "K\[CloseCurlyQuote]an", "Chikchan",
"Kimi", "Manik\[CloseCurlyQuote]", "Lamat", "Muluk", "Ok",
Line 715:
longcountdata = LongCount /@ data;
lotndata = LordOfTheNight /@ data;
{DateObject /@ data, tzolkindata, haabdata, longcountdata, lotndata} // Transpose // Grid</
{{out}}
<pre>Sat 19 Jun 2004 4 Ben 16 Sotz' 12.19.11.6.13 G7
Line 728:
=={{header|Nim}}==
{{trans|Julia}}
<
const
Line 791:
for date in testDates:
let dateStr = date.format("YYYY-MM-dd")
echo &"{dateStr:14} {date.toLongDate:16} {tzolkin(date):9} {haab(date):14} {nightLord(date)}"</
{{out}}
Line 810:
The module <code>Math::BaseArith</code> provides mixed-radix conversion via the <code>encode</code> routine (named as in '''APL''').
{{trans|Raku}}
<
use warnings;
use utf8;
Line 888:
printf "%10s %2s %-9s %4s %-10s %-14s G%d\n",
$date, mayan_calendar_round($date), join('.',mayan_long_count($date)), lord($date);
}</
{{out}}
<pre> Gregorian Tzolk’in Haab’ Long Lord of
Line 906:
=={{header|Phix}}==
{{trans|Go}}
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 984:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</
{{out}}
<pre>
Line 1,005:
{{works with|Python|3.6}}
<
import datetime
Line 1,076:
long, round = g2m(date)
print(date, long, round)
</syntaxhighlight>
{{out}}
Line 1,093:
{{works with|Rakudo|2018.12}}
<syntaxhighlight lang="raku"
Chuwen Eb Ben Hix Men K’ib’ Kaban Etz’nab’ Kawak Ajaw>;
Line 1,164:
printf "%10s %2s %-9s %4s %-10s %-14s %6s\n", Date.new($date),
flat mayan-calendar-round($date), mayan-long-count($date).join('.'), lord($date);
}</
{{out}}
<pre> Gregorian Tzolk’in Haab’ Long Lord of
Line 1,183:
{{libheader|Wren-date}}
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
Line 1,262:
var l = lord.call(date)
Fmt.lprint("$s $2d $-8s $4s $-9s $-14s $s", [dt, n, s, d, m, lc, l])
}</
{{out}}
Line 1,283:
=={{header|zkl}}==
{{trans|Go}}
<
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"),
Line 1,331:
if(rem<=0) rem=9 + rem;
"G%d".fmt(rem)
}</
<
println(" Date # Name Day Month Count the Night");
println("---------- -------- ------------- -------------- ---------");
Line 1,348:
longCount(ymd).concat("."),
lord(ymd)));
});</
{{out}}
<pre>
|