Interfaces
I had two converging urges: on one hand, to see if I could actually figure out something useful to do with the OS X Dashboard, and on the other a piqued interest in the decimal system of keeping time.
The resulting widget works on the web too, with a minor change. The link is at the bottom if you want to peek at it.
Decimal Time
The current mechanism of timekeeping is suboptimal, and the oft-maligned Daylight Savings Time debacle is only the tip of the iceberg. The reason we use the numbers 60 and 12 for time is - according to current understanding - that the great old ones, Sumerians, counted to 12 on the fingers of one hand (your thumb counts each of the three sections of the other four fingers by touch), and another 5 in the other to multiply those to 60 for normal calculations.
Anyway, the system is anachronistic and does not really work very well with the rest of SI, so a base-10 mechanism is the better option. There are plenty of people way more obsessed with this than I on the Net if you are interested in some of the specifics. The French actually gave it a go after one of their revolutions but it did not go very well.
In addition, for this treatise we shall work strictly with UMT (UTC for decimal time, works exactly the same.) Might as well overthrow the entire system, right?
In the Sumerian system, each day has 86 400 seconds (we can leave aside for now the slight astronomical sleights-of-hand with leap seconds and such), which gives a reasonable point to round to decimal: 100 000 decimal seconds per day. Ergo, each decimal second is 0,864 Sumerian seconds.
Obviously, we have 5 powers to work with: hundred-thousandths of a day, are "decimal seconds", but you could also count in ten-thousandths (8,64s), thousandths (1,44min), hundredths (at 14,4min, very handy) or even tenths (144min, or 2h 24min.) Because the hundredths lend themselves easily to percentages, they are the natural fit for the standard time format. The first obvious mental map will be of quarters of a day: 0,0 hours is midnight, 25,0 hours is 6:00, 50,0 hours is noon, and 75,0 naturally 18:00 (or 6pm.) These are easy to offset from UMT: for example, being at UMT+3 currently, 9:00 is 25,0 hours and so on for me.
I chose to represent the number with some extra details; the decimal comma is present at the hundredths (cens, I call them), but faint separators and colour differences in conjunction with explanatory descriptions below help make sense of the number. I was pleasantly surprised that the Dashboard widget correctly shows my abbr-tag "help texts," which brings us to the second topic:
Widget
Apple provides the presumably very useful Dashcode program as a part of the XCode kit for easier development of widgets (Dashboard and Web, apparently), but even at the fully custom template there seemed to be tons of stuff for me to try to wade through (poorly versed as I am with JavaScript), and the UI options, anything from providing your own icons, images etc. up to doing the whole thing in Quartz just seemed a bit too much to put in front of me if I wanted to modify the look from the default. Just to try it out, the default "skin" of course works fine, and maybe the average user is going to be more graphically talented than I am.
At any rate, I had actually tried this out about a month ago on a lark, but gave up because there were tons of Apple's JS and other stuff getting in the way...essentially, I was not sure what all was really needed, what I needed to hook into and so on, and I was having a hard time getting the UI to play nice with the tools provided.
I knew that, ultimately, the widget could just be a HTML+JS application, so this time I set out to do everything from scratch. There seems to be very little information around about this in the last few years (so I assume everyone else is getting around Dashcode much better than I am.) With this Apple document and a couple disparate sources, it did seem that I really could do away with pretty much everything, which is what I did.
Before going further, here is the basic code I ended up with. You will want to disable the code generator before getting started to not have to fight with unnecessary added stuff. After that, I erased everything but the plist files and started off a clean table.
The files of interest are the main.{html,css,js}. I made
a tiny skeleton of a web page, spent entirely too long
getting the style right (for this first draft), and then
wrote the few lines of JS required. The only things that one
pretty much must take into account are the show and hide
events - for most widgets, it is pointless to run when not
shown. I hooked these to my own functions using the load
event from the HTML body. In my case, the show just causes
a timer to start performing the time conversion and updating
the screen at regular intervals (and it still skips a sec
every now and then, sigh, but then we are not exactly
cooking with atomic clock gas here.) Hide just kills the
timers. That, and realising that I can pretty much delete
everything from the disk version of the widget with the
exception of the completely unnecessary Default.png whose
absence will cause the widget to be uninstallable, so save
it!
I will not go into further detail about the actual code here: if interested, see the repository above. The code is very short, and it seems to implement everything that is necessary - and not much more.
Next up, the iPhone...