-
-
Save jevuu/33d5c551709faf7e85236334dcb886b1 to your computer and use it in GitHub Desktop.
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
//Get date and sunrise and sunset times. Compare current time against sunrise and sunset times. Set to night mode. | |
var date = new Date('2018-03-16T23:59:59.000Z'); | |
var sunTimes = SunCalc.getTimes(date, lat, lng); | |
log.info('Current date and time is:' + date + '\nTime for sunset is:' + sunTimes.sunset); | |
if (date > sunTimes.sunriseEnd && date < sunTimes.sunset){ | |
log.info('The sun is up.'); | |
tileUrl = 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png' | |
}else{ | |
log.info('The sun is down. Or error.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment