WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
294815
[JSC] Ensure `Date.prototype.setMonth` and `Date.prototype.setUTCMonth` Respects TimeClip Range by Guarding months of GregorianDateTime Overflow
https://bugs.webkit.org/show_bug.cgi?id=294815
Summary
[JSC] Ensure `Date.prototype.setMonth` and `Date.prototype.setUTCMonth` Respe...
Keita Nonaka
Reported
2025-06-22 15:35:35 PDT
TimeClip[1] function, as referenced in Date.prototype.setMonth[2] and Date.prototype.setUTCMonth[3], mentions that absolute value of time must not exceed 8.64E15 in milliseconds, otherwise returns NaN. However, the current GregorianDateTime class represents years member variable as int. Therefore, if the years exceeds the maximum representable int, date calculations may produce incorrect results. This patch adds a safeguard to ensure that such overflows are prevented to align the behavior with the TC39 spec. [1]:
https://tc39.es/ecma262/#sec-timeclip
[2]:
https://tc39.es/ecma262/#sec-date.prototype.setmonth
[3]:
https://tc39.es/ecma262/#sec-date.prototype.setutcmonth
Attachments
Add attachment
proposed patch, testcase, etc.
Keita Nonaka
Comment 1
2025-06-22 15:37:52 PDT
> However, the current GregorianDateTime class represents years member variable as int. > Therefore, if the years exceeds the maximum representable int, > date calculations may produce incorrect results.
should be However, the current GregorianDateTime class represents months member variable as int. Therefore, if the months exceeds the maximum representable int, date calculations may produce incorrect results.
Keita Nonaka
Comment 2
2025-06-22 15:38:01 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/47036
EWS
Comment 3
2025-06-25 18:40:43 PDT
Committed
296644@main
(7d717f937dac): <
https://commits.webkit.org/296644@main
> Reviewed commits have been landed. Closing PR #47036 and removing active labels.
Radar WebKit Bug Importer
Comment 4
2025-06-25 18:41:16 PDT
<
rdar://problem/154347472
>
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