PlutoTime
JS from http://solarsystem.nasa.gov/plutotime/ exported to use current time and date, not archive time and date (From https://web.archive.org/web/20150605225136/http://solarsystem.nasa.gov/plutotime/)
HTML
<p>Latitude: <input type="text" value="43" id="lat" size="4"></p>
<p>Longitude: <input type="text" value="-85.6" id="lon" size="4"></p>
<button id="btn" class="myButton">Update</button>
<p>Result: </p>
<p><span id="plutoTime"></span></p>
JavaScript
const target_angle = -1.5;
const eccent_earth_orbit = 0.0167042317652;
const sin_obliq_corr = 0.397764267077;
const var_y = 0.0430314896879;
var latitude, longitude, latitude_r, longitude_r
btn.onclick = function() {
update();
}
function update() {
latitude = document.getElementById("lat").value;
longitude = document.getElementById("lon").value;
latitude_r = latitude * Math.PI / 180.;
longitude_r = longitude * Math.PI / 180.;
var jd = get_jd();
var ele = solar_elevation(jd);
var next = find_time(jd);
document.getElementById("plutoTime").innerText = make_text(ele, next, jd);
}
function get_jd() {
var d = new Date();
//alert('d = ' + d);
var unix = d.getTime() * 1e-3;
//alert('unix = ' + unix);
//alert('(unix/86400.)+2440587.5 = ' + (unix/86400.)+2440587.5);
return (unix / 86400.) + 2440587.5;
}
function solar_elevation(julian_date) {
var time_ut = (julian_date - 0.5) - Math.floor(julian_date - 0.5);
var julian_century = (julian_date - 2451545) / 36525.;
var geom_mean_long_sun = (280.46646 + julian_century * (36000.76983 + julian_century * 0.0003032)) % 360;
var gmls_r = geom_mean_long_sun * Math.PI / 180.;
var geom_mean_anom_sun = 357.52911 + julian_century * (35999.05029 - 0.0001537 * julian_century);
var gmas_r = geom_mean_anom_sun * Math.PI / 180.;
var sun_eq_of_ctr_r = (Math.sin(gmas_r) * (1.914602 - julian_century *
(0.004817 + 0.000014 * julian_century)) + Math.sin(2 * gmas_r) *
(0.019993 - 0.000101 * julian_century) + Math.sin(3 * gmas_r) * 0.000289) * Math.PI / 180.;
var sun_app_long_r = gmls_r + sun_eq_of_ctr_r;
var sun_declin_r = Math.asin(sin_obliq_corr * Math.sin(sun_app_long_r));
var eq_of_time = 4 * (180. / Math.PI) * (var_y * Math.sin(2 * gmls_r) -
2 * eccent_earth_orbit * Math.sin(gmas_r) +
4 * eccent_earth_orbit * var_y * Math.sin(gmas_r) * Math.cos(2 * gmls_r) -
0.5 * var_y * var_y * Math.sin(4 *...