[time-nuts] Javascript "Countdown to the Leapsecond" Nixie Clock

Kiwi Geoff geoff36 at gmail.com
Sat Jan 10 06:50:09 UTC 2015


Tom <tvb at leapsecond.com> wrote a few days ago:
> Here's a nixie clock using javascript. It includes a leap second count down
> which is now active:
>     http://leapsecond.com/java/nixie.htm

I have always been fascinated with Tom's delightful "Nixie Clocks" -
how clever !

When I ran the above link a few days ago, I was curious as to whether
the "Countdown" was  correct in the land where local time is UTC+13
hours. So I worked out the "delta" from UTC to the 1st July 2015 and
ended up with a 1 hour difference to that shown on Tom's cute Nixie
tubes.

It was then that I noticed that adding the following Nixie tube times

UTC (hh:mm:ss)  + Countdown (hh:mm:ss) = 25:00:00

At the time of writing - this is a quick way to check whether "your"
computer (and Java engine) can display Tom's (above) Nixie Clock [ the
answer should be 24:00:00 and not 25:00:00 ] - as every second ticks
by.

I was curious as to where this 1 hour problem for my PC came from. So
to learn how Tom's Nixie Clock worked I had a look at the source code.

I couldn't find any "logic" errors - but admired Tom's Nixie clock
even more from how well it was set out and written !

I then wrote some debug code to find out which parts of the clock
acted as I would have expected. The MJD (Modified Julian Date) code
gave answers that matched that from:

http://aa.usno.navy.mil/data/docs/JulianDate.php

Tom's code gave the correct MJD days for "both" Winter and Summer!

Given that good news I decided to change the "Countdown Clock" code
(on my PC only , not an Internet Page) to use MJD times to find the
delta to the "Leap Second" rather than Tom's use of direct millisecond
time.

Here is the modification I made to Tom's "Countdown Clock" (on my PC
only NOT Tom's website! ).



// -------------------------Edit area---------------------------
        // Leap second countdown clock.

        utc = new Date(now.getTime() + (now.getTimezoneOffset() * 60 * 1000));
        var leap = new Date("07/01/2015 00:00:00");

// Geoff Hitchcox (Christchurch , New Zealand)(Kiwi Geoff)
modification, Jan 2015 ,
// by converting TIMES to "Modified Julian Date" (Mjd) it appears to
resolve the HOURS
// correctly in the two different Daylight Saving Time (DST) epochs
(Winter and Summer).
// So Mjd is used to find the DELTA between the two different DST
states (fingers X'd ;-)
         leap = GetMjd(leap) + (GetMjdFraction(leap) / 1E5 );
         utc  = GetMjd(utc)   + (GetMjdFraction(utc)   / 1E5 );
         var ms = (leap - utc) * 86400 * 1000;

// delete this line , Kiwi Geoff , Jan 2015  var ms = leap.getTime() -
(utc.getTime() - 1000);

        if (ms > 0) {
// -------------------------Edit area---------------------------



Using the above "mod" suddenly made Tom's Nixie clock run perfectly on
my PC's and gave ALL the numbers I expected and doing this quick TEST

UTC (hh:mm:ss)  + Countdown (hh:mm:ss) = 24:00:00

The above was my "entertainment" for the early evening - thanks Tom
for your Nixie Clocks !

Regards, Kiwi Geoff (Christchurch , New Zealand).



More information about the Time-nuts_lists.febo.com mailing list