Skip to content

Instantly share code, notes, and snippets.

@ravinggenius
Forked from LeaVerou/dabblet.css
Created December 15, 2014 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravinggenius/69d489260f5a8b484475 to your computer and use it in GitHub Desktop.
Save ravinggenius/69d489260f5a8b484475 to your computer and use it in GitHub Desktop.
HSL clock
/**
* HSL clock
*/
height: 100%;
font: bold 5em/1 Helvetica Neue, sans-serif;
display: flex;
text-align: center;
align-items: center;
justify-content: center;
margin-top: -.1em;
transition: .1s background;
color: white;
text-shadow: 0 0 1px black, 0 0 2px black, 0 0 2px black, 1px 1px black;
<!-- content to be placed inside <body>…</body> -->
setInterval(function(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
document.body.textContent = [h, m, s].map(function(a){ return a < 10? '0' + a : a}).join(':');
// TODO: Shift lightness so that the color is dark at night and light in the day
document.body.style.background = 'hsl(' + ~~(s*6) + ', ' + ~~(m*10/6) + '%, ' + ~~(h*25/6) + '%)';
}, 1000);
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment