Mayan calendar: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m syntax highlighting fixup automation |
Alextretyak (talk | contribs) Added 11l |
||
Line 212: | Line 212: | ||
2020-02-29 |
2020-02-29 |
||
2020-03-01 |
2020-03-01 |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<syntaxhighlight lang="11l"> |
|||
V _DAYS_IN_MONTH = [-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] |
|||
V _DAYS_BEFORE_MONTH = [-1] |
|||
V dbm = 0 |
|||
L(dim) _DAYS_IN_MONTH[1..] |
|||
_DAYS_BEFORE_MONTH.append(dbm) |
|||
dbm += dim |
|||
F _days_before_year(year) |
|||
‘year -> number of days before January 1st of year.’ |
|||
V y = year - 1 |
|||
R y * 365 + y I/ 4 - y I/ 100 + y I/ 400 |
|||
F _is_leap(year) |
|||
‘year -> 1 if leap year, else 0.’ |
|||
R year % 4 == 0 & (year % 100 != 0 | year % 400 == 0) |
|||
F _days_before_month(year, month) |
|||
‘year, month -> number of days in year preceding first day of month.’ |
|||
R :_DAYS_BEFORE_MONTH[month] + (month > 2 & _is_leap(year)) |
|||
F _ymd2ord(year, month, day) |
|||
‘year, month, day -> ordinal, considering 01-Jan-0001 as day 1.’ |
|||
R (_days_before_year(year) + _days_before_month(year, month) + day) |
|||
F g2m(date, gtm_correlation = 1B) |
|||
V correlation = I gtm_correlation {584283} E 584285 |
|||
V long_count_days = [144000, 7200, 360, 20, 1] |
|||
V tzolkin_months = ["Imix'", "Ik'", "Ak'bal", "K'an", ‘Chikchan’, ‘Kimi’, "Manik'", ‘Lamat’, ‘Muluk’, ‘Ok’, ‘Chuwen’, |
|||
‘Eb’, ‘Ben’, ‘Hix’, ‘Men’, "K'ib'", ‘Kaban’, "Etz'nab'", ‘Kawak’, ‘Ajaw’] |
|||
V haad_months = [‘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'"] |
|||
V (year, month, day) = date.split(‘-’).map(Int) |
|||
V gregorian_days = _ymd2ord(year, month, day) |
|||
V julian_days = gregorian_days + 1721425 |
|||
[Int] long_date |
|||
V remainder = julian_days - correlation |
|||
L(days) long_count_days |
|||
(V result, remainder) = divmod(remainder, days) |
|||
long_date.append(Int(result)) |
|||
V long_date_str = (long_date.map(d -> ‘#02’.format(d))).join(‘.’) |
|||
V tzolkin_month = (julian_days + 16) % 20 |
|||
V tzolkin_day = ((julian_days + 5) % 13) + 1 |
|||
V haab_month = Int(((julian_days + 65) % 365) / 20) |
|||
V haab_day = ((julian_days + 65) % 365) % 20 |
|||
V haab_day_str = I haab_day {String(haab_day)} E ‘Chum’ |
|||
V lord_number = (julian_days - correlation) % 9 |
|||
lord_number = I lord_number {lord_number} E 9 |
|||
V round_date = tzolkin_day‘ ’tzolkin_months[tzolkin_month]‘ ’haab_day_str‘ ’haad_months[haab_month]‘ G’lord_number |
|||
R (long_date_str, round_date) |
|||
V dates = [‘2004-06-19’, ‘2012-12-18’, ‘2012-12-21’, ‘2019-01-19’, ‘2019-03-27’, ‘2020-02-29’, ‘2020-03-01’] |
|||
L(date) dates |
|||
V (long, round_date) = g2m(date) |
|||
print(date‘ ’long‘ ’round_date) |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
2004-06-19 12.19.11.06.13 4 Ben 16 Sotz' G7 |
|||
2012-12-18 12.19.19.17.17 1 Kaban Chum K'ank'in G6 |
|||
2012-12-21 13.00.00.00.00 4 Ajaw 3 K'ank'in G9 |
|||
2019-01-19 13.00.06.03.00 1 Ajaw 13 Muwan G6 |
|||
2019-03-27 13.00.06.06.07 3 Manik' Chum Wayeb' G1 |
|||
2020-02-29 13.00.07.05.06 4 Kimi 14 K'ayab G7 |
|||
2020-03-01 13.00.07.05.07 5 Manik' 15 K'ayab G8 |
|||
</pre> |
|||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
<syntaxhighlight lang="fortran"> |
<syntaxhighlight lang="fortran"> |