Bug 129308 (before-mar-1-1000)

Summary: Incorrect date creation prior to 1 Mar 1000
Product: WebKit Reporter: John Wright <johngeorge.wright>
Component: JavaScriptCoreAssignee: Csaba Osztrogonác <ossy>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, benjamin, buildbot, cmarcelo, commit-queue, darin, ggaren, ossy, rniwa
Priority: P2    
Version: 525.x (Safari 3.2)   
Hardware: All   
OS: OS X 10.9   
Attachments:
Description Flags
Patch
buildbot: commit-queue-
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2
none
Patch v2
buildbot: commit-queue-
Archive of layout-test-results from webkit-ews-11 for mac-mountainlion-wk2
none
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion
none
Patch v3
none
Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2
none
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion
none
Tests
none
Patch
buildbot: commit-queue-
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2
none
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion
none
Patch v2 none

Description John Wright 2014-02-25 06:45:50 PST
Creating date's prior to 1 Mar 1000 will create a date object a day too early.

Here's example code:


// Correct dates
new Date("1 Jan 1900"); // Mon Jan 01 1900 00:00:00 GMT+0000 (GMT)
new Date("1 Jan 1500"); // Mon Jan 01 1500 00:00:00 GMT+0000 (GMT)
new Date("1 Jan 1001"); // Thu Jan 01 1001 00:00:00 GMT+0000 (GMT)
new Date("1 Mar 1000"); // Sat Mar 01 1000 00:00:00 GMT+0000 (GMT)

// In correct dates
new Date("28 Feb 1000"); // Thu Feb 27 1000 00:00:00 GMT+0000 (GMT)
new Date("1 Dec 988"); // Sun Nov 30 0988 00:00:00 GMT+0000 (GMT)
Comment 1 Tibor Mészáros 2014-03-24 12:00:55 PDT
Created attachment 227674 [details]
Patch

There were a bug in the leap year check, so I fixed it, and added new test to show that it's working.
Comment 2 Build Bot 2014-03-24 12:52:48 PDT
Comment on attachment 227674 [details]
Patch

Attachment 227674 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5436077191987200

New failing tests:
http/tests/cookies/simple-cookies-expired.html
http/tests/cache/subresource-expiration-1.html
sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T11.html
js/dom/date-big-constructor.html
js/date-parse-test.html
http/tests/cache/subresource-expiration-2.html
http/tests/misc/last-modified-parsing.html
js/dom/date-DST-time-cusps.html
js/date-parse-comments-test.html
js/date-constructor.html
js/date-toisostring.html
js/dom/date-big-setdate.html
Comment 3 Build Bot 2014-03-24 12:52:51 PDT
Created attachment 227683 [details]
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-05  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 4 Build Bot 2014-03-24 15:50:51 PDT
Comment on attachment 227674 [details]
Patch

Attachment 227674 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4903125974515712

New failing tests:
http/tests/cookies/simple-cookies-expired.html
js/date-constructor.html
sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T11.html
js/dom/date-big-constructor.html
js/date-parse-test.html
http/tests/misc/last-modified-parsing.html
js/dom/date-DST-time-cusps.html
js/date-parse-comments-test.html
js/date-toisostring.html
js/dom/date-big-setdate.html
Comment 5 Build Bot 2014-03-24 15:50:53 PDT
Created attachment 227698 [details]
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-14  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 6 Tibor Mészáros 2014-03-25 06:39:42 PDT
Created attachment 227745 [details]
Patch v2

Fixed the time zone problem.
Comment 7 Build Bot 2014-03-25 07:37:58 PDT
Comment on attachment 227745 [details]
Patch v2

Attachment 227745 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5104956688302080

New failing tests:
http/tests/cookies/simple-cookies-expired.html
js/date-constructor.html
sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T11.html
js/dom/date-big-constructor.html
js/date-parse-test.html
http/tests/misc/last-modified-parsing.html
js/dom/date-DST-time-cusps.html
js/date-parse-comments-test.html
js/date-toisostring.html
js/dom/date-big-setdate.html
Comment 8 Build Bot 2014-03-25 07:38:00 PDT
Created attachment 227747 [details]
Archive of layout-test-results from webkit-ews-11 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-11  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 9 Build Bot 2014-03-25 08:00:08 PDT
Comment on attachment 227745 [details]
Patch v2

Attachment 227745 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5197840187916288

New failing tests:
http/tests/cookies/simple-cookies-expired.html
http/tests/cache/subresource-expiration-1.html
sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T11.html
js/dom/date-big-constructor.html
js/date-parse-test.html
http/tests/cache/subresource-expiration-2.html
http/tests/misc/last-modified-parsing.html
js/dom/date-DST-time-cusps.html
js/date-parse-comments-test.html
js/date-constructor.html
js/date-toisostring.html
js/dom/date-big-setdate.html
Comment 10 Build Bot 2014-03-25 08:00:11 PDT
Created attachment 227749 [details]
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-05  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 11 Tibor Mészáros 2014-03-25 08:21:48 PDT
Created attachment 227752 [details]
Patch v3
Comment 12 Build Bot 2014-03-25 09:17:00 PDT
Comment on attachment 227752 [details]
Patch v3

Attachment 227752 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5727751910719488

New failing tests:
http/tests/cookies/simple-cookies-expired.html
js/date-constructor.html
sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T11.html
js/dom/date-big-constructor.html
js/date-parse-test.html
http/tests/misc/last-modified-parsing.html
js/dom/date-DST-time-cusps.html
js/date-parse-comments-test.html
js/date-toisostring.html
js/dom/date-big-setdate.html
Comment 13 Build Bot 2014-03-25 09:17:03 PDT
Created attachment 227757 [details]
Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-15  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 14 Build Bot 2014-03-25 09:42:09 PDT
Comment on attachment 227752 [details]
Patch v3

Attachment 227752 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5664647029981184

New failing tests:
http/tests/cookies/simple-cookies-expired.html
http/tests/cache/subresource-expiration-1.html
sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T11.html
js/dom/date-big-constructor.html
js/date-parse-test.html
http/tests/cache/subresource-expiration-2.html
http/tests/misc/last-modified-parsing.html
js/dom/date-DST-time-cusps.html
js/date-parse-comments-test.html
js/date-constructor.html
js/date-toisostring.html
js/dom/date-big-setdate.html
Comment 15 Build Bot 2014-03-25 09:42:12 PDT
Created attachment 227761 [details]
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-04  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 16 Csaba Osztrogonác 2014-04-07 06:33:26 PDT
(In reply to comment #0)
> Creating date's prior to 1 Mar 1000 will create a date object a day too early.
> 
> Here's example code:
> 
> 
> // Correct dates
> new Date("1 Jan 1900"); // Mon Jan 01 1900 00:00:00 GMT+0000 (GMT)
> new Date("1 Jan 1500"); // Mon Jan 01 1500 00:00:00 GMT+0000 (GMT)
> new Date("1 Jan 1001"); // Thu Jan 01 1001 00:00:00 GMT+0000 (GMT)
> new Date("1 Mar 1000"); // Sat Mar 01 1000 00:00:00 GMT+0000 (GMT)
> 
> // In correct dates
> new Date("28 Feb 1000"); // Thu Feb 27 1000 00:00:00 GMT+0000 (GMT)
> new Date("1 Dec 988"); // Sun Nov 30 0988 00:00:00 GMT+0000 (GMT)

https://trac.webkit.org/changeset/165667 fixed these failing tests too.

*** This bug has been marked as a duplicate of bug 130123 ***
Comment 17 Csaba Osztrogonác 2014-04-07 06:36:11 PDT
Otherwise we could add new test cases to avoid future regressions.
Comment 18 Tibor Mészáros 2014-04-08 10:02:27 PDT
Created attachment 228847 [details]
Tests

The missing tests for this bug.
Comment 19 Darin Adler 2014-04-09 07:29:50 PDT
Comment on attachment 228847 [details]
Tests

Could you re-upload a version that correctly applies so that the EWS can run the tests?
Comment 20 Csaba Osztrogonác 2014-04-10 01:12:42 PDT
Reopening to attach new patch.
Comment 21 Csaba Osztrogonác 2014-04-10 01:12:47 PDT
Created attachment 229029 [details]
Patch

patch for landing
Comment 22 Build Bot 2014-04-10 02:30:26 PDT
Comment on attachment 229029 [details]
Patch

Attachment 229029 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/6720383478661120

New failing tests:
js/date-constructor.html
Comment 23 Build Bot 2014-04-10 02:30:30 PDT
Created attachment 229037 [details]
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-08  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 24 Csaba Osztrogonác 2014-04-10 03:05:06 PDT
failures:

FAIL new Date(Date.parse('28 Feb 1000 GMT')).toGMTString() should be Thu, 28 Feb 1000 00:00:00 GMT. Was Fri, 28 Feb 1000 00:00:00 GMT.
FAIL new Date(Date.parse('1 Dec 988 GMT')).toGMTString() should be Sun, 01 Dec 0988 00:00:00 GMT. Was Mon, 01 Dec 0988 00:00:00 GMT.
Comment 25 Build Bot 2014-04-10 03:09:06 PDT
Comment on attachment 229029 [details]
Patch

Attachment 229029 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5010492573614080

New failing tests:
js/date-constructor.html
Comment 26 Build Bot 2014-04-10 03:09:16 PDT
Created attachment 229038 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 27 Build Bot 2014-04-10 03:34:56 PDT
Comment on attachment 229029 [details]
Patch

Attachment 229029 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5718194736070656

New failing tests:
js/date-constructor.html
Comment 28 Build Bot 2014-04-10 03:35:01 PDT
Created attachment 229039 [details]
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-01  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 29 Csaba Osztrogonác 2014-04-10 05:17:39 PDT
Comment on attachment 229029 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229029&action=review

> LayoutTests/js/script-tests/date-constructor.js:51
> +shouldBe("new Date(Date.parse('28 Feb 1000 GMT')).toGMTString()", "\"Thu, 28 Feb 1000 00:00:00 GMT\"");
> +shouldBe("new Date(Date.parse('1 Dec 988 GMT')).toGMTString()", "\"Sun, 01 Dec 0988 00:00:00 GMT\"");
> +shouldBe("new Date(Date.parse('1 Mar 1000 GMT')).toGMTString()", "\"Sat, 01 Mar 1000 00:00:00 GMT\"");

It seems only the results should be updated:
- 01 Mar 1000 - it is next to 28 Feb 1000, so it is friday
- 01 Dec 0988 - it is monday as WebKit says now
Comment 30 Tibor Mészáros 2014-04-10 07:23:12 PDT
Created attachment 229049 [details]
Patch v2

Fixed tests.
Comment 31 Darin Adler 2014-04-12 12:04:58 PDT
Comment on attachment 229049 [details]
Patch v2

View in context: https://bugs.webkit.org/attachment.cgi?id=229049&action=review

> LayoutTests/ChangeLog:3
> +        (before-mar-1-1000) In correct date creation prior to 1 Mar 1000 

incorrect spelling of incorrect here
Comment 32 WebKit Commit Bot 2014-04-12 12:34:31 PDT
Comment on attachment 229049 [details]
Patch v2

Clearing flags on attachment: 229049

Committed r167184: <http://trac.webkit.org/changeset/167184>
Comment 33 WebKit Commit Bot 2014-04-12 12:34:37 PDT
All reviewed patches have been landed.  Closing bug.