Famously, presenters of Radio 4's Today programme occasionally have trouble telling the time. Although this endears them to regular listeners, the clock below is designed to help. Alongside a traditional analogue clock, a secondary clock is presented that spells out the time in the style of spoken English (actually British English, since our American cousins do it differently).
To incorporate in a web page simply include the
today-clock.js script and
two div elements – one with the
today-clock class and the other with the
today-tell-time class – sized and arranged to suit your design.
(In fact, there are no dependencies between the two clock components and either can be omitted.)
On load, the script populates any div that has the
today-clock class with an analogue clock and populates any div that has the
today-tell-time class with a 'tell time' clock.
Both clocks auto-size to fill the containing div (even dynamically if the containing div
is resizable, although the current implementation depends on a window.resize event).
However, the analogue clock will always maintain a 1:1 aspect ratio no matter
what the aspect ratio of its containing div. The 'tell time' clock will stretch to match the
size of its container div but looks best with an aspect ratio of 3:1.
Supported browsers: Uses the HTML5 canvas element. Should work in any modern web browser and may work in IE9.
Accuracy: The clock simply echoes that of the client machine. Where ultimate precision is needed (as in the Today studio) the computer's clock should be synchronised with a reliable time server, such as ntp2d.mcc.ac.uk
Source code can be scraped from this page or downloaded from GitHub.
today-clock.js depends on JQuery. A copy of jquery-1.4.2.min.js is included. Alternatively, include this script tag in your HTML file:
Copyright (c) 2013 David Easley, http://easleyonline.appspot.com/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.