Sunday, 28 July 2013

A Binary Clock In Dart

Binary Clocks - simple stuff, just the time in binary right? Well, it turns out that is not the case. Some transfer the 4 digits of the time into 4 binary numbers. Critics have pointed out that this binary coded decimal is not pure enough and scientifically insufficiently geeky.

Of course, this is all just a bit of fun. They are rather impractical! I liked it colourful for this blog so that was my main aim when I set about the task of writing my own (as a Dart WebUI Component - I guess it will be polymer.dart soon). The Dart libs have and easy method to get milliseconds since epoch. To get seconds we can simply round to 1000. For display, I chose 24 bits and decided to show previous times. This means our binary number updates at the LSB more often (right hand side of our string of 1's and 0's. The clock would look rather static other than at the right edge so I mirrored the display which gives some pleasing patterns. This gives time for around 200 days - so on some planet, this could be quite useful! Code as always on Github.