Leap Second
esskar
created: 2005-12-30 20:47:11
The next leap second will hit us tonite. The question is: can Date::Calc handle it ? :-)
Re: Leap Second
created: 2005-12-30 21:01:43
It doesn't have to. Under Unix time keeping, leap seconds don't exist. Computer clocks will have to be adjusted.
Perl --((8:>*
Re^2: Leap Second
created: 2005-12-31 12:13:39
It doesn't have to. Under Unix time keeping, leap seconds don't exist. Computer clocks will have to be adjusted.

While the the whole POSIX time / leap seconds issue is a rather complicated mess (for those interested in gory details see The Future of Leap Seconds, History of IEEE P1003.1 POSIX time and Unix time) I'm not sure how it's relevant to how Date::Calc handles leap seconds?

Indeed, as documented, Date::Calc says that Time_to_Date() and Date_to_Time() take/return UTC time values that include leap seconds. The documentation appears to be lying though :-)

Re: Leap Second
created: 2005-12-30 21:59:02

The leap seconds are not assigned on a regular basis. While leap years arrive predictably, leap seconds don't. The only way for a computer to know about leap seconds is to be connected to something similar to an RFC-867 time server NIST Internet Time Service. Can Date::Calc manage that? I've no clue, although there would seem to be no reason why a clever Perl programmer (i.e., not me) couldn't write Date::Calc:RFC-867 module to check for leap seconds.

emc

" When in doubt, use brute force." — Ken Thompson
Re^2: Leap Second
created: 2005-12-31 03:15:48
The leap seconds are not assigned on a regular basis. While leap years arrive predictably, leap seconds don't. The only way for a computer to know about leap seconds is to be connected to something similar to an RFC-867 time server NIST Internet Time Service.
Well, that's not the only way. While leap seconds aren't assigned on a regular basis, they are announced way in advance, and leap seconds in the past aren't erased. 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.
Perl --((8:>*
Re^3: Leap Second
created: 2005-12-31 03:57:55
and leap seconds in the past aren't erased.

Leap seconds can need to be subtracted, (due to nutation?), though this is likely to occur much less frequently than their being added. It also doesn't detract from your quoted point, but does complicate things a little.

I also read(search for IERS) that leap seconds are only added on June 31st30th or December 31st, so bi-annual updates should suffice.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Re^4: Leap Second
created: 2005-12-31 05:35:22

only added on June 31s

31 June would be a leapday, right? Guess you were thinking about 30 June, the last day of the month.

Cheers, Sören

Re^5: Leap Second
created: 2005-12-31 06:21:08

Indeed. Thanks, corrected.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Re^4: Leap Second
created: 2006-01-01 00:15:02
In an "emergency", IERS could add leap seconds at the end of March or September. Presumably this would happen with less than the 6 months less a few days warning that June/December leap seconds get.
Re^4: Leap Second
created: 2006-01-01 18:31:29
I also read(search for IERS) that leap seconds are only added on June 30th or December 31st, so bi-annual updates should suffice.
But you don't want to update your lists at the times leap seconds are added (or skipped). We're talking about Date::Calc, and some people use it to calculate dates in the future. You want to update your lists as soon as it has been decided a leap second will be added or skipped. I don't know how often people meet to determine whether we'll need another leap second, but I doubt it's more often than four times a year.
Perl --((8:>*
Re^3: Leap Second
created: 2005-12-31 12:53:16

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
Re^4: Leap Second
created: 2006-01-01 18:27:09
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:>*
Re^5: Leap Second
created: 2006-01-01 21:47:02

Touché

emc

" When in doubt, use brute force." — Ken Thompson
Re^4: Leap Second
created: 2006-01-01 18:37:41
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:>*
Re^5: Leap Second
created: 2006-01-01 21:38:31

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."L is a one-digit code that indicates whether a leap second will be added or subtracted at midnight on the last day of the current month. If the code is 0, no leap second will occur this month. If the code is 1, a positive leap second will be added at the end of the month. This means that the last minute of the month will contain 61 seconds instead of 60. If the code is 2, a second will be deleted on the last day of the month. Leap seconds occur at a rate of about one per year. They are used to correct for irregularity in the earth's rotation. The correction is made just before midnight UTC (not local time)." 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
Re^6: Leap Second
created: 2006-01-02 04:00:22
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^7: Leap Second
created: 2006-01-02 12:23:41

For the first part: true, within the limits of RFC-867 as implemented by NIST.

For the second: the list of past leap seconds is known, and universal. Much more difficult to modify Date::Calc to be useful before the Julian to Gregorian calendar change overs (which, as I'm sure you know, varied by the countries extant at the time).

It's a separate question as to whether someone would want to allow for leap seconds or not, which is why I suggested (semi-seriously) Date::Calc::RFC-867. It can be done, within limits. Date::Calc does have admitted limits; it can't give me the date for Easter before 1583 (say, I want to answer the question: "How many solar eclipses visible in Europe fell on Easter?"). So, as a sensible programmer, I realize I can't use Date::Calc to answer that question. If I want to know on Nov 30, 2005-- using just the information available from NIST's implementation of RFC-867 -- what time it was 8 days, 3 hours, 44 minutes, 16 seconds before noon on Jan 1, 2006 -- I'd have to allow for the fact the time calculated on Dec 1, 2005 may be a second different. Incidentally, I'm not proposing, in any manner, that the current functionality of Date::Calc be modified. Some users may find an RFC-867 extension to be useful, but modifying the way Date::Calc works currently would probably break far too many programs. The current changes to the US DST rules are going to cause enough disruption, as it is.

emc

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

perlmonks.org content © perlmonks.org and adrianh, BrowserUk, esskar, Happy-the-monk, Perl Mouse, swampyankee, ysth

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03