src/util/SunPosition.js
function (date) {
                if (date instanceof Date === false) {
                    throw new ArgumentError(
                        Logger.logMessage(Logger.LEVEL_SEVERE, "SunPosition", "computeJulianDate", "missingDate"));
                }

                var year = date.getUTCFullYear();
                var month = date.getUTCMonth() + 1;
                var day = date.getUTCDate();
                var hour = date.getUTCHours();
                var minute = date.getUTCMinutes();
                var second = date.getUTCSeconds();

                var dayFraction = (hour + minute / 60 + second / 3600) / 24;

                if (month <= 2) {
                    year -= 1;
                    month += 12;
                }

                var A = Math.floor(year / 100);
                var B = 2 - A + Math.floor(A / 4);
                var JD0h = Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + B - 1524.5;

                return JD0h + dayFraction;
            }
function (date) {
                if (date instanceof Date === false) {
                    throw new ArgumentError(
                        Logger.logMessage(Logger.LEVEL_SEVERE, "SunPosition", "computeJulianDate", "missingDate"));
                }

                var year = date.getUTCFullYear();
                var month = date.getUTCMonth() + 1;
                var day = date.getUTCDate();
                var hour = date.getUTCHours();
                var minute = date.getUTCMinutes();
                var second = date.getUTCSeconds();

                var dayFraction = (hour + minute / 60 + second / 3600) / 24;

                if (month <= 2) {
                    year -= 1;
                    month += 12;
                }

                var A = Math.floor(year / 100);
                var B = 2 - A + Math.floor(A / 4);
                var JD0h = Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + B - 1524.5;

                return JD0h + dayFraction;
            }
function ( date ) { if ( date instanceof Date === false ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "SunPosition" , "computeJulianDate" , "missingDate" ) ) ; } var year = date . getUTCFullYear ( ) ; var month = date . getUTCMonth ( ) + 1 ; var day = date . getUTCDate ( ) ; var hour = date . getUTCHours ( ) ; var minute = date . getUTCMinutes ( ) ; var second = date . getUTCSeconds ( ) ; var dayFraction = ( hour + minute / 60 + second / 3600 ) / 24 ; if ( month <= 2 ) { year -= 1 ; month += 12 ; } var A = Math . floor ( year / 100 ) ; var B = 2 - A + Math . floor ( A / 4 ) ; var JD0h = Math . floor ( 365.25 * ( year + 4716 ) ) + Math . floor ( 30.6001 * ( month + 1 ) ) + day + B - 1524.5 ; return JD0h + dayFraction ; }
Computes the julian date from a javascript date object
@param {Date} date
@throws {ArgumentError} if the date is missing
@return {Number} the julian date
Computes the julian date from a javascript date object