Bug 137342

Summary: Incorrect adding time to Date object for January 1st
Product: WebKit Reporter: Igor Kosulin <justvamp>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Major CC: ggaren, mark.lam
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows 8   

Description Igor Kosulin 2014-10-02 05:12:24 PDT
Reproducing:

Run this script:

<script>
var dt = new Date();
dt.setYear(2008);  // any of these years: 1991, 2002, 2008, 2013, 2019, 2030, 2036, 2041, 2047, 2058...
dt.setMonth(0, 1); // January 1st
dt.setHours(23);
dt.setMinutes(30);
dt.setSeconds(0);

console.log(dt.toString());
dt.setMinutes(dt.getMinutes() + 30)
console.log(dt.toString());
</script>

Excepted result (it works this way for other dates/years):
Thu Jan 01 2008 23:30:00 GMT+0300
Fri Jan 02 2008 00:00:00 GMT+0300

But we have:
Tue Jan 01 2008 23:30:00 GMT+0300
Tue Jan 01 2008 23:00:00 GMT+0300

This bug seems to be reproduced only for January 1st and only for years like 1991, 2002, 2008, 2013, 2019, 2030, 2036, 2041, 2047, 2058...

===

Also please take a look at another testcase. It's also pretty weird:

<script>
var dt = new Date();
dt.setYear(2008);  // any of these years: 1991, 2002, 2008, 2013, 2019, 2030, 2036, 2041, 2047, 2058...
dt.setMonth(0, 1); // January 1st
dt.setHours(23);
dt.setMinutes(30);
dt.setSeconds(0);

console.log(dt.toString());
var dt2 = new Date(dt.getTime() + 30 * 60000);
console.log(dt2.toString());
<script>

Excepted result (it works this way for other dates/years):
Thu Jan 01 2008 23:30:00 GMT+0300
Fri Jan 02 2008 00:00:00 GMT+0300

But we have:
Tue Jan 01 2008 23:30:00 GMT+0300
Wed Jan 02 2008 01:00:00 GMT+0400
Comment 1 Geoffrey Garen 2014-10-02 23:58:48 PDT
<rdar://problem/18536183>