console.log("Sunset:" + sunset); console.log("Sunrise:" + sunrise); var t = today.getHours() + today.getMinutes()/60; console.log("NOW: "+t); if (t >= sunrise && t < sunset) { return false; } return true; } function onDayNightSwitch() { console.log("onDayNightSwitch"); if (dayNightMode === "auto") { console.log("Change map mode to: "+!nightMode); setNightMode(isNight()); } } Are you referring to the bold? Edit: and why?