Re: is it Time bug?



Pat Maddox <pergesu@xxxxxxxxx> writes:

> First of all for doing stuff like this I highly recommend checking out
> Runt [1], it's a temporal expression library. Think regular
> expressions for time.
>
> Anyway I think it has to do with the fact that that the Date lib
> accounts for leap years, but your code doesn't. To explain it a bit..
>
> There are 365.25 days in a year, not 365. This means that there are
> 31557600 seconds in a year, rather than the 31536000 that your code
> would generate. That leaves you with 21600 unnoticed seconds. 365 /
> 21600 = 0.0168981481, which is how many seconds are lost in each day.
> There are 63 days between your start date of Sep 01 and the "weird"
> date of Nov 02. 63 * 0.0168981481 = 1.03, so there's one lost second,
> causing the day to not roll over.
>
> Pretty fun, huh? :)

I don't believe that this is the cause of the problem here. Changing
the dates from 5/1/2005 to 7/11/2005 (just shifting everything back 4
months) does not cause the same effect. This is a daylight savings time
issue, not a seconds-per-year issue. In 2005, daylight savings time
went into effect on April 3, 2005, and terminated on 30 October, 2005
... at least in the USA.

t1 = Time.mktime(2005, 5, 1)
t2 = Time.mktime(2005, 7, 11)
while t1.to_i < t2.to_i
p t1
t1 += 3600*24*7
end

Sun May 01 00:00:00 EDT 2005
Sun May 08 00:00:00 EDT 2005
Sun May 15 00:00:00 EDT 2005
Sun May 22 00:00:00 EDT 2005
Sun May 29 00:00:00 EDT 2005
Sun Jun 05 00:00:00 EDT 2005
Sun Jun 12 00:00:00 EDT 2005
Sun Jun 19 00:00:00 EDT 2005
Sun Jun 26 00:00:00 EDT 2005
Sun Jul 03 00:00:00 EDT 2005
Sun Jul 10 00:00:00 EDT 2005

Every day has exactly 86400 seconds (except every few years when a
leap-second is added/subtracted). The seconds-per-year issue is covered
by leap years.

--
Lloyd Zusman
ljz@xxxxxxxxxx
God bless you.



.



Relevant Pages

  • A Suggestion for Abolishing the Leap Second
    ... the problems in Internet timekeeping caused by leap seconds, ... they accept daylight savings time - it would mean that while waiting ... But I have another suggestion. ... yet it would have the same exact precision as ...
    (sci.geo.satellite-nav)
  • A Suggestion For Abolishing the Leap Second
    ... the problems in Internet timekeeping caused by leap seconds, ... they accept daylight savings time - it would mean that while waiting ... But I have another suggestion. ... yet it would have the same exact precision as ...
    (comp.protocols.time.ntp)
  • Re: using perl to print yesterdays date, but with formatting options ?
    ... It works for daylight savings time, ... DST changes, leap seconds, leap years, other calender systems and much more :-) ... You boys need to think in terms of both longitudal regions ...
    (comp.lang.perl.misc)
  • Re: A Suggestion For Abolishing the Leap Second
    ... Leap second implementation is a mature and well ... they accept daylight savings time - it would mean that while waiting ... leap seconds and atomic time had provided. ... leap seconds is irregular and has to do with both the rotation of the ...
    (comp.protocols.time.ntp)
  • Re: Sheryl Crow
    ... a busy time in Iowa....what with the leap into ... daylight savings time and all......yer gonna have ... Anyone else like Sheryl Crow? ... Crow is a little snake in the grass. ...
    (rec.music.gdead)