WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
4892
Date constructor has problems with months larger than 11
https://bugs.webkit.org/show_bug.cgi?id=4892
Summary
Date constructor has problems with months larger than 11
Ruairi Mc Comb
Reported
2005-09-08 13:27:17 PDT
When creating dates in the following manner: new Date(year, month, date); If the month is larger than 11, the date returned starts going random. I've tested the page with Firefox (1.0.6 OSX, 1.0.1 & 1.0.6 WinXP) and IE (WinXP 6.0.2900) and if the month is larger than 11 these browsers update the date accordingly (e.g. if month is 13, they add 1 year and 2 months).
Attachments
Demonstration of the bug.
(242 bytes, text/html)
2005-09-08 13:29 PDT
,
Ruairi Mc Comb
no flags
Details
Patch to wrap month around inside Date constructor, and Date.UTC.
(1.53 KB, patch)
2005-09-11 01:46 PDT
,
Mark Rowe (bdash)
darin
: review-
Details
Formatted Diff
Diff
Layout test
(2.34 KB, text/html)
2005-09-11 16:19 PDT
,
Mark Rowe (bdash)
no flags
Details
Updated patch
(1.65 KB, patch)
2005-09-11 22:20 PDT
,
Mark Rowe (bdash)
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Ruairi Mc Comb
Comment 1
2005-09-08 13:29:02 PDT
Created
attachment 3820
[details]
Demonstration of the bug.
Mark Rowe (bdash)
Comment 2
2005-09-11 01:13:52 PDT
Confirmed with WebKit 412.7 and ToT WebKit. In the ECMA 262 spec, section 15.9.1.12 (the MakeDay operator) it mentions that the year should be set to year + floor(month / 12), and the month to month % 12. This logic is currently implemented in date_object.cpp's fillStructuresUsingDateArgs. The Date constructor does not make use of this function, so the adjustment never takes place. It looks that Date.UTC suffers from the same problem.
Mark Rowe (bdash)
Comment 3
2005-09-11 01:46:24 PDT
Created
attachment 3858
[details]
Patch to wrap month around inside Date constructor, and Date.UTC. I will add some layout tests shortly.
Mark Rowe (bdash)
Comment 4
2005-09-11 16:19:03 PDT
Created
attachment 3866
[details]
Layout test This layout test covers both the Date constructor and Date.UTC.
Darin Adler
Comment 5
2005-09-11 21:54:26 PDT
Comment on
attachment 3858
[details]
Patch to wrap month around inside Date constructor, and Date.UTC. This fix doesn't look right to me. I think handling things like this is part of the job of the makeTime function, so we should fix that instead of doing this.
Mark Rowe (bdash)
Comment 6
2005-09-11 22:20:00 PDT
Created
attachment 3868
[details]
Updated patch This patch moves the existing month wrapping from inside fillStructuresUsingDateArgs into makeTime so that it handles the Date constructor and Date.UTC case.
Darin Adler
Comment 7
2005-09-11 22:25:50 PDT
Comment on
attachment 3868
[details]
Updated patch Looks great. One complaint: The comment mentions CFGregorianDate overflow, but that's only one reason to adjust the year and do %= on the month. The other is to work best with the year offset machinery, and it applies even on non-Mac-OS-X.
Geoffrey Garen
Comment 8
2005-09-18 11:17:22 PDT
***
Bug 4782
has been marked as a duplicate of this bug. ***
Kevin Smith
Comment 9
2007-11-13 14:26:18 PST
Has this actually been released in the latest version of Safari 2.0.4? Because I still have a problem with this code: var test = new Date(this.VisibleDate.getFullYear(),this.VisibleDate.getMonth()+(this.MonthRows*this.MonthColumns);
Darin Adler
Comment 10
2007-11-13 14:35:19 PST
(In reply to
comment #9
)
> Has this actually been released in the latest version of Safari 2.0.4?
No. It's fixed for Safari 3.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug