What's the Mayan date?

Python 3, 149 \$\cdots\$ 145 140 bytes

from datetime import*
def f(d):
 n,s=(date(*d)-date(1,1,1)).days+1137143,""
 for i in[144000,7200,360,20,1]:s+=f".{n//i}";n%=i
 return s[1:]

Try it online!

Takes Gregorian date as [year, month, day] list and returns Mayan date as f"{B'ak'tun}.{K'atun}.{Tun}.{Winal}.{Day}"(loosely as a python f-string).


JavaScript (ES6), 96 bytes

Assumes that the system is set up to UTC time (as the TIO servers are)

Takes input as 3 distinct parameters (year, month, day).

(y,m,d)=>[144e3,7200,360,20,1].map(k=>n/(n%=k,k)|0,n=new Date(y+4e3,m-1,d+395335)/864e5).join`.`

Try it online!

How?

We can't safely pass a year \$y<100\$ to the Date constructor, as it gets interpreted as \$1900+y\$. To work around this issue, we add \$4000\$ to the year. We make sure to use a multiple of \$400\$ so that we have the same properties regarding leap years.

The remaining number of days to reach Epoch from August 11, 3114 BCE + 4000 years is \$395335\$.


05AB1E, 54 52 bytes

365*Š3‹¹α4т‚DPª÷®β•ë˜¿•ºS₂+²£`•H`Ø•OŽQív₂y-‰R`})R'.ý

Try it online!

First step: compute the day number.

365                # literal 365
   *               # multiply
                   #  => 365*year is left on the stack for now
Š                  # get the other two inputs
                   #  => day is left on the stack
3‹                 # is month less than 3? (returns 0 or 1)
  ¹α               # absolute difference with year
    4              # literal 4
     т             # 100
      ‚            # pair the two: [4, 100]
       DP          # product of (a copy of) the pair: 400
         ª         # append it to to the pair: [4, 100, 400]
          ÷        # int divide the year by each of those numbers
           ®β      # convert from base -1: y/4 - y/100 + y/400
                   #  => number of leap days is left on the stack
•ë˜¿•              # compressed integer 15254545
     º             # mirrored: 1525454554545251
      S            # split to a list of digits
       ₂+          # add 26 to each: [27, 31, 28, 31, 30, ...]
         ²£        # month first values of that list
           `       # dump all on the stack
                   #  => days in previous months is left on the stack
•H`Ø•              # compressed integer 1136750
                   #  => gregorian-mayan offset is left on the stack
O                  # sum the stack, giving the # of days since 0.0.0.0.0

Second step: convert that number to the appropriate notation.

ŽQí                # compressed integer 6866
   v      }        # for each digit:
    ₂y-            #  26 - digit (20, 18, 20, 20)
       ‰R`         #  divmod, reverse, then dump
                   #  (pushes the mod then the div)
           )       # wrap the stack in an array
            R      # reverse
             '.ý   # join by "."