Bug 137342 - Incorrect adding time to Date object for January 1st
Summary: Incorrect adding time to Date object for January 1st
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows 8
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-10-02 05:12 PDT by Igor Kosulin
Modified: 2014-10-02 23:58 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>