On May 31, 4:15 pm, Bas Dirks <
i...@basdirks.eu> wrote:
> Is there a reason that you can't update to a more recent version?
I think this has something to do with the fact that it's the 31st
here:
15.9.5.38 Date.prototype.setMonth (month [, date ] )
If date is not specified, this behaves as if date were specified with
the value getDate().
1. Let t be the result of LocalTime(this time value).
2. Let m be ToNumber(month).
3. If date is not specified, then let dt be DateFromTime(t);
otherwise, let dt be ToNumber(date).
4. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt),
TimeWithinDay(t)).
5. Let u be TimeClip(UTC(newDate)).
6. Set the [[PrimitiveValue]] internal property of this Date object to
u.
7. Return u.
Note the getDate bit. So:
> var date = new Date()
> date.getDate()
31
> date.setMonth(1); date
Fri, 04 Mar 2011 01:25:13 GMT
> date.getDate()
3
> // overflow due to February being the 28th as the last day
> date.setMonth(1); date
Fri, 04 Feb 2011 01:25:13 GMT
> date.setMonth(0); date
Tue, 04 Jan 2011 01:25:13 GMT
---
Looks like there's some overflow happening on months.