Created
May 4, 2020 01:27
-
-
Save nilayk/aed80a15ecda1d3ff108e581701bb881 to your computer and use it in GitHub Desktop.
Today evening's golden hour times in console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var showPosition = function(position) { | |
var times = SunCalc.getTimes(new Date(), position.coords.latitude, position.coords.longitude); | |
console.log("Today evening's golden hour is from: " + times.goldenHour.toLocaleTimeString() + " to " + times.sunset.toLocaleTimeString()); | |
}; | |
var s = document.createElement("script"); | |
s.type = "text/javascript"; | |
s.onload = function() { | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(showPosition); | |
} | |
}; | |
s.src = "https://cdn.jsdelivr.net/gh/mourner/suncalc/suncalc.js"; | |
var e = document.getElementsByTagName('script')[0]; | |
e.parentNode.insertBefore(s, e); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment