: julian day *///* latitude : latitude of observer in degrees *///* longitude : longitude of observer in degrees *///* Return value: *///* julian day of the most recent sunset *///***********************************************************************/ function findRecentSunset(jd, latitude, longitude) { var julianday = jd; var time = calcSunsetUTC(julianday, latitude, longitude); while(!isNumber(time)){ julianday -= 1.0; time = calcSunsetUTC(julianday, latitude, longitude); } return julianday; }//***********************************************************************///* Name: findNextSunrise *///* Type: Function *///* Purpose: calculate the julian day of the next sunrise *///* starting from the given day at the given location on earth *///* Arguments: *///* JD : julian day *///* latitude : latitude of observer in degrees *///* longitude : longitude of observer in degrees *///* Return value: *///* julian day of the next sunrise *///***********************************************************************/ function findNextSunrise(jd, latitude, longitude) { var julianday = jd; var time = calcSunriseUTC(julianday, latitude, longitude); while(!isNumber(time)){ julianday += 1.0; time = calcSunriseUTC(julianday, latitude, longitude); } return julianday; }//***********************************************************************///* Name: findNextSunset *///* Type: Function *///* Purpose: calculate the julian day of the next sunset *///* starting from the given day at the given location on earth *///* Arguments: *///* JD : julian day *///* latitude : latitude of observer in degrees *///* longitude : longitude of observer in degrees *///* Return value: *///* julian day of the next sunset *///***********************************************************************/ function findNextSunset(jd, latitude, longitude) { var julianday = jd; var time = calcSunsetUTC(julianday, latitude, longitude); while(!isNumber(time)){ julianday += 1.0; time = calcSunsetUTC(julianday, latitude, longitude); } return julianday; }//***********************************************************************///* Name: timeString *///* Type: Function *///* Purpose: convert time of day in minutes to a zero-padded string *///* suitable for printing to the form text fields *///* Arguments: *///* minutes : time of day in minutes *///* Return value: *///* string of the format HH:MM:SS, minutes and seconds are zero padded*///***********************************************************************/ function timeString(minutes) // timeString returns a zero-padded string (HH:MM:SS) given time in minutes { var floatHour = minutes / 60; var hour = Math.floor(floatHour); var floatMinute = 60 * (floatHour - Math.floor(floatHour)); var minute = Math.floor(floatMinute); var floatSec = 60 * (floatMinute - Math.floor(floatMinute)); var second = Math.floor(floatSec); var timeStr = hour + ":"; if (minute < 10) // i.e. only one digit timeStr += "0" + minute + ":"; else timeStr += minute + ":"; if (second < 10) // i.e. only one digit timeStr += "0" + second; else timeStr += second; return timeStr; }//***********************************************************************///* Name: timeStringShortAMPM *///* Type: Function *///* Purpose: convert time of day in minutes to a zero-padded string *///* suitable for printing to the form text fields. If time *///* crosses a day boundary, date is appended. *///* Arguments: *///* minutes : time of day in minutes *///* JD : julian day *///* Return value: *///* string of the format HH:MM[AM/PM] (DDMon) *///***********************************************************************/// timeStringShortAMPM returns a zero-padded string (HH:MM *M) given time in // minutes and appends short date if time is > 24 or < 0, resp. function timeStringShortAMPM(minutes, JD) { var julianday = JD; var floatHour = minutes / 60; var hour = Math.floor(floatHour); var floatMinute = 60 * (floatHour - Math.floor(floatHour)); var minute = Math.floor(floatMinute); var floatSec = 60 * (floatMinute - Math.floor(floatMinute)); var second