Mayan calendar: Difference between revisions

m
syntax highlighting fixup automation
(Python 3.6 code for mayan calendar solving task)
m (syntax highlighting fixup automation)
Line 213:
2020-03-01
=={{header|Fortran}}==
<syntaxhighlight lang="fortran">
<lang Fortran>
PROGRAM MAYA_DRIVER
IMPLICIT NONE
Line 375:
END SUBROUTINE maya_time
 
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 390:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 491:
fmt.Printf("%s %2d %-8s %4s %-9s %-14s %s\n", dt, n, s, d, m, lc, l)
}
}</langsyntaxhighlight>
 
{{out}}
Line 511:
 
Implementation:
<langsyntaxhighlight Jlang="j">require 'types/datetime'
 
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</langsyntaxhighlight>
 
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:
<langsyntaxhighlight Jlang="j"> gmt 2004 6 19
June 19, 2004
4 Ben 16 Sotz’ G7
Line 575:
March 1, 2019
3 Imix’ 14 K’ayab G2
13.0.5.13.1</langsyntaxhighlight>
 
=={{header|Julia}}==
{{trans|Go}}
<langsyntaxhighlight lang="julia">using Dates
 
const Tzolk´in = [
Line 632:
rpad(haab(date), 15), nightlord(date))
end
</langsyntaxhighlight>{{out}}
<pre>
Gregorian Long Count Tzolk´in Haab´ Nightlord
Line 649:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">sacred = {"Imix\[CloseCurlyQuote]", "Ik\[CloseCurlyQuote]",
"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</langsyntaxhighlight>
{{out}}
<pre>Sat 19 Jun 2004 4 Ben 16 Sotz' 12.19.11.6.13 G7
Line 728:
=={{header|Nim}}==
{{trans|Julia}}
<langsyntaxhighlight Nimlang="nim">import math, strformat, times
 
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)}"</langsyntaxhighlight>
 
{{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}}
<langsyntaxhighlight lang="perl">use strict;
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);
}</langsyntaxhighlight>
{{out}}
<pre> Gregorian Tzolk’in Haab’ Long Lord of
Line 906:
=={{header|Phix}}==
{{trans|Go}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,005:
{{works with|Python|3.6}}
 
<langsyntaxhighlight lang="python">
import datetime
 
Line 1,076:
long, round = g2m(date)
print(date, long, round)
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,093:
{{works with|Rakudo|2018.12}}
 
<syntaxhighlight lang="raku" perl6line>my @sacred = <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,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);
}</langsyntaxhighlight>
{{out}}
<pre> Gregorian Tzolk’in Haab’ Long Lord of
Line 1,183:
{{libheader|Wren-date}}
{{libheader|Wren-fmt}}
<langsyntaxhighlight lang="ecmascript">import "/date" for Date
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])
}</langsyntaxhighlight>
 
{{out}}
Line 1,283:
=={{header|zkl}}==
{{trans|Go}}
<langsyntaxhighlight lang="zkl">var [const]
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)
}</langsyntaxhighlight>
<langsyntaxhighlight lang="zkl">println(" Gregorian Tzolk'in Haab' Long Lord of");
println(" Date # Name Day Month Count the Night");
println("---------- -------- ------------- -------------- ---------");
Line 1,348:
longCount(ymd).concat("."),
lord(ymd)));
});</langsyntaxhighlight>
{{out}}
<pre>
10,351

edits