The root problem here is the assumption that a day is always 24 hours. 
In timezones that support DST, a day can actually be 23, 24, or 25 hours
long.  Your posted code is adding 24-hour periods to a given date, so
assuming you want to keep it that way you can just add the difference
between the timezone offsets of the two dates to your projected date:

tday = new Date(2006,9,16,22,49,18,0);
res = new Date(tday.getTime() + 16*24*60*60*1000);
test = new Date(2006,10,1,22,49,18,0);
test.setTime(test.getTime() + (tday.getTimezoneOffset() -
res.getTimezoneOffset()) * 60000);
assertTrue( "Test: 16 via addDays(),\nNeed: 2006-11-01 22:49:18 (plus or
minus 1 hour due to DST)\nComp: "+res+"\nTest: "+test+"\n",
res.getTime()==test.getTime());



--- In [email protected], "Mike Crowe" <[EMAIL PROTECTED]> wrote:
>
> Dude, you may be my new hero. I need to figure out how to handle
> this.
>
> Anybody coded for DST before? Pointers?
>
> Mike
>
> --- In [email protected], "Pekka Kola" pekka.kola@
> wrote:
> >
> > Daylight saving time btw Oct 16 .. Nov 1??
> >
> > BR, Pekka
> >
> > -----Original Message-----
> > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> > Behalf Of Mike Crowe
> > Sent: 17. lokakuuta 2006 6:32
> > To: [email protected]
> > Subject: [flexcoders] Bug in Date() class math
> >
> > Hi folks,
> >
> > I submitted this bug to Adobe today. I was trying to figure out
> why
> > my Date routines wouldn't work. Here's a test function which fails:
> >
> > The following code appears to mis-compute the result date. This is
> > adding 16 days to the current date:
> >
> > public function testMike():void {
> > var tday:Date;
> > var res:Date;
> > var test:Date;
> >
> > tday = new Date(2006,9,16,22,49,18,0);
> > res = new Date(tday.getTime() + 16*24*60*60*1000);
> > test = new Date(2006,10,1,22,49,18,0);
> > assertTrue( "Test: 16 via addDays(),\nNeed: 2006-11-01
> > 22:49:18\nComp: "+res+"\nTest: "+test+"\n", res==test);
> >
> > }
> >
> > Results:
> >
> > Error: Test: 16 via addDays(),
> > Need: 2006-11-01 22:49:18
> > Comp: Wed Nov 1 21:49:18 GMT-0500 2006
> > Test: Wed Nov 1 22:49:18 GMT-0500 2006
> > - expected true but was false
> >
> >
> > My unit-test goes from 1-100 days (by 5), All dates below 16 days
> > work.
> >
> > Anybody else see this?
> > TIA
> > Mike
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/
> flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/
> flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to