Created
April 17, 2014 18:44
-
-
Save jtauber/11004048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculated Coordinated Mars Time (MTC) | |
var d = new Date(); | |
var millis = d.getTime(); | |
var jd_ut = 2440587.5 + (millis / 8.64E7); | |
var jd_tt = jd_ut + (35 + 32.184) / 86400; | |
var j2000 = jd_tt - 2451545.0; | |
var msd = (((j2000 - 4.5) / 1.027491252) + 44796.0 - 0.00096); | |
var mtc = (24 * msd) % 24; | |
// then output MTC with h_to_hms(mtc) defined as: | |
function h_to_hms(h) { | |
var x = h * 3600; | |
var hh = Math.floor(x / 3600); | |
if (hh < 10) hh = "0" + hh; | |
var y = x % 3600; | |
var mm = Math.floor(y / 60); | |
if (mm < 10) mm = "0" + mm; | |
var ss = Math.round(y % 60); | |
if (ss < 10) ss = "0" + ss; | |
return hh + ":" + mm + ":" + ss; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment