DennouNeko

JD to Mayan

Dec 14th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var MAYAN_COUNT_EPOCH = 584282.5;
  2.  
  3. function jd_to_mayan_count(jd)
  4. {
  5.     var d, baktun, katun, tun, uinal, kin;
  6.  
  7.     jd = Math.floor(jd) + 0.5;
  8.     d = jd - MAYAN_COUNT_EPOCH;
  9.     baktun = Math.floor(d / 144000);
  10.     d = mod(d, 144000);
  11.     katun = Math.floor(d / 7200);
  12.     d = mod(d, 7200);
  13.     tun = Math.floor(d / 360);
  14.     d = mod(d, 360);
  15.     uinal = Math.floor(d / 20);
  16.     kin = mod(d, 20);
  17.  
  18.     return new Array(baktun, katun, tun, uinal, kin);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment