Code: Select all
var d = new Date();
var thours = d.getHours();
var tmins = d.getMinutes();
var sunrise = "<#sunrise>"; // this is replaced by Cumulus with eg '07:40'
var sunset = "<#sunset>"; // this is replaced by Cumulus with eg '18:35'
var srh = parseFloat(sunrise.slice(0,2)); // chop up string and turn into numbers
var srm = parseFloat(sunrise.slice(3));
var ssh = parseFloat(sunset.slice(0,2));
var ssm = parseFloat(sunset.slice(3));
if (((thours == srh && tmins > srm) || (thours > srh)) && ((thours < ssh) || (thours == ssh && tmins <= ssm)))
{ document.write("<link href='weatherstyle.css' rel='stylesheet' type='text/css' />"); }
else
{ document.write("<link href='weatherstyle_night.css' rel='stylesheet' type='text/css' />"); }
DN