Pat Maddox
1/30/2006 10:26:00 AM
On 1/30/06, Lloyd Zusman <ljz@asfast.com> wrote:
> Pat Maddox <pergesu@gmail.com> 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.
Yeah, I realized that. To quote my reply to Joel, who uncovered the real issue:
"Damn, you win. Thought I had found an interesting 'gotcha' :)"