1 /** 2 * Determine if year is a leap year. 3 */ 4 function isLeapYear(inputYear) { 5 var year = inputYear; 6 7 if (year % 4 == 0) { 8 if (year % 100 == 0) 9 return (year % 400 == 0) ? true : false; 10 else 11 return true; 12 } 13 else 14 return false; 15 } 16 17 /** 18 * Round a number (value) to specified number of decimal places (precision) 19 */ 20 function round(value, precision) { 21 var multiplier = Math.pow(10, precision || 0); 22 23 return Math.round(value * multiplier) / multiplier; 24 } 25 26 /** 27 * Convert radians to degrees. 28 */ 29 function radiansToDegrees(radians) { 30 return radians * Math.PI / 180; 31 } 32 33 /** 34 * Convert degrees to radians. 35 */ 36 function degreesToRadians(degrees) { 37 return degrees * (Math.PI / 180); 38 } 39 40 41 module.exports = { 42 isLeapYear, 43 round, 44 radiansToDegrees, 45 degreesToRadians 46 };