Closed
Bug 9939
Opened 26 years ago
Closed 26 years ago
new Date (year, month, negative day) sets day to 1
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
VERIFIED
FIXED
People
(Reporter: martin.honnen, Assigned: mike+mozilla)
Details
Attachments
(1 file)
|
171 bytes,
text/html
|
Details |
Calling
new Date(1999, 6, -6)
shows
Thu Jul 01 00:00:00 GMT+0200 (W. Europe Daylight Time) 1999
while in NN3 and IE it shows
Thu Jun 24 00:00:00 W. Europe Daylight Time 1999
On a short glance at ecma I think the nn3 and IE behaviour is correct.
| Reporter | ||
Comment 1•26 years ago
|
||
| Assignee | ||
Updated•26 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 2•26 years ago
|
||
Martin -
Looks like you're correct. Hopefully this is rare enough that it hasn't tripped
anyone up...
Are there any other similar bugs where negative arguments should be interpreted,
but are not?
Thanks -
Mike
| Assignee | ||
Comment 3•26 years ago
|
||
Martin - thanks for finding the problem!
This diff fixes it.
There was a specific check for date < 1, which leads me to believe that this is
the only case where we ignored a negative argument.
cvs diff jsdate.c
Index: jsdate.c
===================================================================
RCS file: /cvsroot/mozilla/js/src/jsdate.c,v
retrieving revision 3.18
diff -r3.18 jsdate.c
1798c1798,1802
< array[loop] = 0;
---
> if (loop == 2) { /* Default date argument to 1. */
> array[loop] = 1;
> } else {
> array[loop] = 0;
> }
1809,1813d1812
<
< /* if we got a 0 for 'date' (which is out of range)
< * pretend it's a 1 */
< if (array[2] < 1)
< array[2] = 1;
Awaiting an open tree to check it in on.
| Assignee | ||
Updated•26 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 4•26 years ago
|
||
Checked in a fix.
You need to log in
before you can comment on or make changes to this bug.
Description
•