--- In [email protected], Stephen Allison 
<[EMAIL PROTECTED]> wrote:
>
> > parseDate.setMonth(++parseDate.month);
> >
> Then that statement above gives different results to:
> ++parseDate.month
> parseDate.setMonth(parseDate.month);
> 
> which gives:
> 
> Sat Nov 1 00:00:00 GMT+0000 2008 Sun Feb 1 00:00:00 GMT+0000 2009
> Mon Dec 1 00:00:00 GMT+0000 2008 Sun Feb 1 00:00:00 GMT+0000 2009
> Thu Jan 1 00:00:00 GMT+0000 2009 Sun
> 
> (i.e. it behaves as you would expect)
> 
> Shouldn't the two versions be executed the same way? - i.e. month 
is  
> incremented from 11 to 0 by the ++month (causing the year 
rollover)  
> and then this 0 is passed into setMonth which should just set it to 
0  
> again and cause no rollover.  The call to setMonth is superfluous  
> (though personally I'd go with setDate(parseDate.month + 1)) but  
> shouldn't actually be doing anything as in both above cases it's 
just  
> being passed 0 and so should either cause a year rollover in both  
> cases (which would be buggy but consistent) or in neither case, 
that  
> it's different is a bit worrying.

See, I didn't realize you could just increment the month that way :-
).  I thought that the setMonth() method was there in lieu of having 
a setter on month.

-Amy

Reply via email to