I forked this code from clock.