in reply to Re^2: Leap Second
in thread Leap Second

A module dealing with leap seconds could just use a plain text file to store the leap seconds. A cron job to check the validity of the file run four times a year will be enough.

But where's the fun in that? More fun (this is why my kids think I'm nuts) would be to write a module to just read the RFC-867 data from the NIST Internet Time Service and do it automatically.

I just think it would take a Perlist who is either better than I am or has more free time. Preferably both. Any volunteers?

emc

" When in doubt, use brute force." — Ken Thompson

Replies are listed 'Best First'.
Re^4: Leap Second
by Perl Mouse (Chaplain) on Jan 01, 2006 at 23:37 UTC
    More fun (this is why my kids think I'm nuts) would be to write a module to just read the RFC-867 data from the NIST Internet Time Service and do it automatically.
    How would you actually do that? RFC-867 seems to be a protocol to send the current time - how would you use that to determine when leap seconds have happened? Even if you'd now start querying the server every second to determine a possible leap second, it wouldn't really help Date::Calc - you have no information about leap seconds in the past, nor about any upcoming leap seconds.
    Perl --((8:>*

      The package definition used by NIST (apparently RFC-867 doesn't define the packet very well) includes a flag which inidicates whether a leap second will be added or subtracted at the end of the month.

       Since the leap second correction is always (with NIST) on the last day of the month, it would really only be necessary to check sometime before midnight on the last day of the month.

      emc

      " When in doubt, use brute force." — Ken Thompson
        Then it won't work most of the time, will it? It's only useful if you want to make a calculation in December spanning the next end of the month. It won't help you if you want to calculate what's 8 days, 12 hour, 39 minutes and 17 seconds past noon on Christmas, and you want to have the answer on Thanksgivings day. Or if you want to know what time it was 50,000 seconds ago in the morning of January 1.

        There have been 23 leap seconds since 1972. For Date::Calc style calculations, you need to know all of them. At any moment. Just knowing whether there will be one at the end of the current month won't do.

        Perl --((8:>*
Re^4: Leap Second
by Perl Mouse (Chaplain) on Jan 01, 2006 at 23:27 UTC
    But where's the fun in that?
    The fun is disproving that your statement The only way for a computer to know about leap seconds ... is false.

    Perl --((8:>*

      Touché

      emc

      " When in doubt, use brute force." — Ken Thompson