Skip to content

Instantly share code, notes, and snippets.

@nilayk
Created May 4, 2020 01:27
Show Gist options
  • Save nilayk/aed80a15ecda1d3ff108e581701bb881 to your computer and use it in GitHub Desktop.
Save nilayk/aed80a15ecda1d3ff108e581701bb881 to your computer and use it in GitHub Desktop.
Today evening's golden hour times in console
(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