Commit cff83f5c authored by tkent@chromium.org's avatar tkent@chromium.org

Change lower and higher limits of date/datetime/datetime-local/month/week types

https://bugs.webkit.org/show_bug.cgi?id=39737

Reviewed by Darin Adler.

WebCore:

According to the latest draft of HTML5, ISO-8601 dates in HTML5
should support A.D.0001 in Gregorian calendar though Gregorian
calendar started in 1582. So, we change the lower limits of
date&time types to 0001-01-01T00:00.

We also introduce the common higher limit, 275760-09-13T00:00. It
is the higher limit of Date type of ECMAScript.

* html/DateComponents.cpp:
(WebCore::DateComponents::parseYear):
 Rejects years less than A.D.1 and years greater than 275760.
(WebCore::withinHTMLDateLimits):
 Helper functions to check lower and higher limits.
(WebCore::DateComponents::addDay):
 - Remove an overflow check. 'year' can't be so large number because
   parseYear() rejects such numbers.
 - Add withinHTMLDateLimits() calls.
(WebCore::DateComponents::addMinute):
 - Add an assertion for the base date.
 - Add withinHTMLDateLimits() calls.
(WebCore::DateComponents::parseMonth):
 Add withinHTMLDateLimits() call.
(WebCore::DateComponents::parseDate): ditto.
(WebCore::DateComponents::parseWeek): ditto.
(WebCore::DateComponents::parseDateTimeLocal): ditto.
(WebCore::DateComponents::parseDateTime): ditto.
(WebCore::DateComponents::setMillisecondsSinceEpochForDate): ditto.
(WebCore::DateComponents::setMillisecondsSinceEpochForDateTime): ditto.
(WebCore::DateComponents::setMillisecondsSinceEpochForMonth): ditto.
(WebCore::DateComponents::setMonthsSinceEpoch):
 Add year range check and withinHTMLDateLimits() call.
(WebCore::DateComponents::setMillisecondsSinceEpochForWeek):
 Add year range check and week range check.
* html/DateComponents.h:
 Update minimum/maximum constant values.
(WebCore::DateComponents::minimumDate):
(WebCore::DateComponents::minimumDateTime):
(WebCore::DateComponents::minimumMonth):
(WebCore::DateComponents::minimumWeek):
(WebCore::DateComponents::maximumDate):
(WebCore::DateComponents::maximumDateTime):
(WebCore::DateComponents::maximumMonth):
(WebCore::DateComponents::maximumWeek):

LayoutTests:

Update tests and test results for the new DateComponents behavior.

* fast/forms/ValidityState-rangeOverflow-expected.txt:
* fast/forms/ValidityState-stepMismatch-expected.txt:
* fast/forms/ValidityState-typeMismatch-date-expected.txt:
* fast/forms/ValidityState-typeMismatch-datetime-expected.txt:
* fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt:
* fast/forms/ValidityState-typeMismatch-month-expected.txt:
* fast/forms/ValidityState-typeMismatch-week-expected.txt:
* fast/forms/input-valueasdate-date-expected.txt:
* fast/forms/input-valueasdate-datetime-expected.txt:
* fast/forms/input-valueasdate-month-expected.txt:
* fast/forms/input-valueasdate-week-expected.txt:
* fast/forms/input-valueasnumber-date-expected.txt:
* fast/forms/input-valueasnumber-datetime-expected.txt:
* fast/forms/input-valueasnumber-datetimelocal-expected.txt:
* fast/forms/input-valueasnumber-month-expected.txt:
* fast/forms/input-valueasnumber-week-expected.txt:
* fast/forms/script-tests/ValidityState-rangeOverflow.js:
* fast/forms/script-tests/ValidityState-stepMismatch.js:
* fast/forms/script-tests/ValidityState-typeMismatch-date.js:
* fast/forms/script-tests/ValidityState-typeMismatch-datetime.js:
* fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js:
* fast/forms/script-tests/ValidityState-typeMismatch-month.js:
* fast/forms/script-tests/ValidityState-typeMismatch-week.js:
* fast/forms/script-tests/input-valueasdate-date.js:
* fast/forms/script-tests/input-valueasdate-datetime.js:
* fast/forms/script-tests/input-valueasdate-month.js:
* fast/forms/script-tests/input-valueasdate-week.js:
* fast/forms/script-tests/input-valueasnumber-date.js:
* fast/forms/script-tests/input-valueasnumber-datetime.js:
* fast/forms/script-tests/input-valueasnumber-datetimelocal.js:
* fast/forms/script-tests/input-valueasnumber-month.js:
* fast/forms/script-tests/input-valueasnumber-week.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 725b1869
2010-08-29 Kent Tamura <tkent@chromium.org>
Reviewed by Darin Adler.
Change lower and higher limits of date/datetime/datetime-local/month/week types
https://bugs.webkit.org/show_bug.cgi?id=39737
Update tests and test results for the new DateComponents behavior.
* fast/forms/ValidityState-rangeOverflow-expected.txt:
* fast/forms/ValidityState-stepMismatch-expected.txt:
* fast/forms/ValidityState-typeMismatch-date-expected.txt:
* fast/forms/ValidityState-typeMismatch-datetime-expected.txt:
* fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt:
* fast/forms/ValidityState-typeMismatch-month-expected.txt:
* fast/forms/ValidityState-typeMismatch-week-expected.txt:
* fast/forms/input-valueasdate-date-expected.txt:
* fast/forms/input-valueasdate-datetime-expected.txt:
* fast/forms/input-valueasdate-month-expected.txt:
* fast/forms/input-valueasdate-week-expected.txt:
* fast/forms/input-valueasnumber-date-expected.txt:
* fast/forms/input-valueasnumber-datetime-expected.txt:
* fast/forms/input-valueasnumber-datetimelocal-expected.txt:
* fast/forms/input-valueasnumber-month-expected.txt:
* fast/forms/input-valueasnumber-week-expected.txt:
* fast/forms/script-tests/ValidityState-rangeOverflow.js:
* fast/forms/script-tests/ValidityState-stepMismatch.js:
* fast/forms/script-tests/ValidityState-typeMismatch-date.js:
* fast/forms/script-tests/ValidityState-typeMismatch-datetime.js:
* fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js:
* fast/forms/script-tests/ValidityState-typeMismatch-month.js:
* fast/forms/script-tests/ValidityState-typeMismatch-week.js:
* fast/forms/script-tests/input-valueasdate-date.js:
* fast/forms/script-tests/input-valueasdate-datetime.js:
* fast/forms/script-tests/input-valueasdate-month.js:
* fast/forms/script-tests/input-valueasdate-week.js:
* fast/forms/script-tests/input-valueasnumber-date.js:
* fast/forms/script-tests/input-valueasnumber-datetime.js:
* fast/forms/script-tests/input-valueasnumber-datetimelocal.js:
* fast/forms/script-tests/input-valueasnumber-month.js:
* fast/forms/script-tests/input-valueasnumber-week.js:
2010-08-29 Yuzo Fujishima <yuzo@google.com>
Unreviewed Chromium test expectation change for r66296.
......@@ -14,7 +14,7 @@ PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-27".
PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-28".
PASS The value "2010-01-27" doesn't overflow the maximum value "2011-01-26".
PASS The value "foo" doesn't overflow the maximum value "2011-01-26".
PASS The value "2010-01-27" doesn't overflow the maximum value "1000-01-01".
PASS The value "2010-01-27" doesn't overflow the maximum value "0000-01-01".
PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
PASS The value "9999-01-01" overflows the maximum value "2010-12-31".
PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
......@@ -27,7 +27,7 @@ PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2010-01-2
PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2010-01-27T12:34:56Z".
PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2011-01-26T12:34Z".
PASS The value "foo" doesn't overflow the maximum value "2011-01-26T12:34Z".
PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "1000-01-01T00:00Z".
PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "0000-01-01T00:00Z".
PASS The value "2010-01-27T12:34Z" overflows the maximum value "2010-01-26T12:33:59.999Z".
PASS The value "9999-01-01T23:59Z" overflows the maximum value "2010-12-31T00:00Z".
PASS The value "2010-01-27T12:34Z" overflows the maximum value "2010-01-26T12:34Z".
......@@ -40,7 +40,7 @@ PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2010-01-27
PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2010-01-27T12:34:56".
PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2011-01-26T12:34".
PASS The value "foo" doesn't overflow the maximum value "2011-01-26T12:34".
PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "1000-01-01T00:00".
PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "0000-01-01T00:00".
PASS The value "2010-01-27T12:34" overflows the maximum value "2010-01-26T12:33:59.999".
PASS The value "9999-01-01T23:59" overflows the maximum value "2010-12-31T00:00".
PASS The value "2010-01-27T12:34" overflows the maximum value "2010-01-26T12:34".
......@@ -53,7 +53,7 @@ PASS The value "2010-01" doesn't overflow the maximum value "2010-01".
PASS The value "2010-01" doesn't overflow the maximum value "2010-02".
PASS The value "2010-01" doesn't overflow the maximum value "2011-01".
PASS The value "foo" doesn't overflow the maximum value "2011-01".
PASS The value "2010-01" doesn't overflow the maximum value "1000-01".
PASS The value "2010-01" doesn't overflow the maximum value "0000-01".
PASS The value "2010-01" overflows the maximum value "2009-12".
PASS The value "9999-01" overflows the maximum value "2010-12".
PASS The value "2010-01" overflows the maximum value "2009-12".
......@@ -93,7 +93,8 @@ PASS The value "2010-W01" doesn't overflow the maximum value "2010-W01".
PASS The value "2010-W01" doesn't overflow the maximum value "2010-W02".
PASS The value "2010-W01" doesn't overflow the maximum value "2011-W01".
PASS The value "foo" doesn't overflow the maximum value "2011-W01".
PASS The value "2010-W01" doesn't overflow the maximum value "1582-W01".
PASS The value "2010-W01" doesn't overflow the maximum value "0000-W01".
PASS The value "2010-W01" overflows the maximum value "1582-W01".
PASS The value "2010-W01" overflows the maximum value "2009-W12".
PASS The value "9999-W01" overflows the maximum value "2010-W12".
PASS The value "2010-W01" overflows the maximum value "2009-W50".
......
......@@ -42,8 +42,10 @@ PASS stepMismatchFor("2010-02-09T12:34:55Z", "0.333", "2010-02-09T12:34:56Z") is
PASS stepMismatchFor("2010-02-09T12:34:55.001Z", "0.333", "2010-02-09T12:34:56Z") is false
PASS stepMismatchFor("2010-02-09T12:34Z", "86400", "2010-02-08T12:34Z") is false
PASS stepMismatchFor("2010-02-09T12:34:56Z", "86400", "2010-02-08T12:34Z") is true
PASS stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-13T23:50:50Z") is true
PASS stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-13T23:50:50Z") is false
PASS stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-12T23:59:50Z") is true
PASS stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-12T23:59:50Z") is false
PASS stepMismatchFor("0001-01-01T00:00Z", "3", "0001-01-11T00:00:02Z") is true
PASS stepMismatchFor("0001-01-01T00:00Z", "2", "0001-01-11T00:00:02Z") is false
Implicit step base
PASS stepMismatchFor("1970-01-01T12:34Z", "120", null) is false
PASS stepMismatchFor("1970-01-01T12:35Z", "120", null) is true
......@@ -70,8 +72,10 @@ PASS stepMismatchFor("2010-02-09T12:34:55", "0.333", "2010-02-09T12:34:56") is t
PASS stepMismatchFor("2010-02-09T12:34:55.001", "0.333", "2010-02-09T12:34:56") is false
PASS stepMismatchFor("2010-02-09T12:34", "86400", "2010-02-08T12:34") is false
PASS stepMismatchFor("2010-02-09T12:34:56", "86400", "2010-02-08T12:34") is true
PASS stepMismatchFor("275760-09-13T00:00", "3", "275760-09-13T23:50:50") is true
PASS stepMismatchFor("275760-09-13T00:00", "2", "275760-09-13T23:50:50") is false
PASS stepMismatchFor("275760-09-13T00:00", "3", "275760-09-12T23:59:50") is true
PASS stepMismatchFor("275760-09-13T00:00", "2", "275760-09-12T23:59:50") is false
PASS stepMismatchFor("0001-01-01T00:00", "3", "0001-01-11T00:00:02") is true
PASS stepMismatchFor("0001-01-01T00:00", "2", "0001-01-11T00:00:02") is false
Implicit step base
PASS stepMismatchFor("1970-01-01T12:34", "120", null) is false
PASS stepMismatchFor("1970-01-01T12:35", "120", null) is true
......
......@@ -6,8 +6,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS "" is a correct valid date string.
PASS "2009-09-07" is a correct valid date string.
PASS "9999-12-31" is a correct valid date string.
PASS "2147483647-12-31" is a correct valid date string.
PASS "275760-09-13" is a correct valid date string.
PASS "1582-10-15" is a correct valid date string.
PASS "0001-01-01" is a correct valid date string.
PASS "2009-01-31" is a correct valid date string.
PASS "2009-02-28" is a correct valid date string.
PASS "2009-03-31" is a correct valid date string.
......@@ -25,15 +26,15 @@ PASS "2000-02-29" is a correct valid date string.
PASS " 2009-09-07 " is a correct invalid date string.
PASS "a" is a correct invalid date string.
PASS "-1-09-07" is a correct invalid date string.
PASS "1581-09-07" is a correct invalid date string.
PASS "1582-10-14" is a correct invalid date string.
PASS "0000-12-31" is a correct invalid date string.
PASS "0000-01-01" is a correct invalid date string.
PASS "275760-09-14" is a correct invalid date string.
PASS "2147483648-12-31" is a correct invalid date string.
PASS "2009/09/07" is a correct invalid date string.
PASS "20090907" is a correct invalid date string.
PASS "2009--2-07" is a correct invalid date string.
PASS "2009-00-07" is a correct invalid date string.
PASS "2009-13-07" is a correct invalid date string.
PASS "1582-09-30" is a correct invalid date string.
PASS "2009-xx-30" is a correct invalid date string.
PASS "2009-01-32" is a correct invalid date string.
PASS "2009-02-29" is a correct invalid date string.
......
......@@ -10,11 +10,12 @@ PASS "2009-09-07T16:49:31.1Z" is a correct valid datetime string.
PASS "2009-09-07T16:49:31.12Z" is a correct valid datetime string.
PASS "2009-09-07T16:49:31.123Z" is a correct valid datetime string.
PASS "2009-09-07T16:49:31.1234567890Z" is a correct valid datetime string.
PASS "2147483647-12-31T23:59:59.999Z" is a correct valid datetime string.
PASS "1582-10-15T00:00:00.000Z" is a correct valid datetime string.
PASS "1582-10-15T00:00:00.000+00:00" is a correct valid datetime string.
PASS "1582-10-15T01:30+01:30" is a correct valid datetime string.
PASS "1582-10-15T00:00+01:00" is a correct valid datetime string.
PASS "275760-09-12T23:59:59.999Z" is a correct valid datetime string.
PASS "275760-09-13T00:00:00.000Z" is a correct valid datetime string.
PASS "0001-01-01T00:00:00.000Z" is a correct valid datetime string.
PASS "0001-01-01T00:00:00.000+00:00" is a correct valid datetime string.
PASS "0001-01-01T01:30+01:30" is a correct valid datetime string.
PASS "0001-01-01T00:00+01:00" is a correct valid datetime string.
PASS " 2009-09-07T16:49Z " is a correct invalid datetime string.
PASS "2009-09-07T16:49z" is a correct invalid datetime string.
PASS "2009-09-07t16:49Z" is a correct invalid datetime string.
......@@ -30,7 +31,7 @@ PASS "2009-09-07T16:49-23" is a correct invalid datetime string.
PASS "2009-09-07T16:49-23:" is a correct invalid datetime string.
PASS "2009-09-07T16:49-24:00" is a correct invalid datetime string.
PASS "2009-09-07T16:49-23:60" is a correct invalid datetime string.
PASS "1582-10-14T23:59:59Z" is a correct invalid datetime string.
PASS "0000-12-31T23:59:59Z" is a correct invalid datetime string.
PASS "2147483647-12-31T23:59-00:01" is a correct invalid datetime string.
PASS "2147483648-01-01T00:00:00Z" is a correct invalid datetime string.
PASS successfullyParsed is true
......
......@@ -10,16 +10,16 @@ PASS "2009-09-07T16:49:31.1" is a correct valid datetime-local string.
PASS "2009-09-07T16:49:31.12" is a correct valid datetime-local string.
PASS "2009-09-07T16:49:31.123" is a correct valid datetime-local string.
PASS "2009-09-07T16:49:31.1234567890" is a correct valid datetime-local string.
PASS "2147483647-12-31T23:59:59.999" is a correct valid datetime-local string.
PASS "1582-10-15T00:00:00.000" is a correct valid datetime-local string.
PASS "275760-09-13T00:00:00.000" is a correct valid datetime-local string.
PASS "0001-01-01T00:00:00.000" is a correct valid datetime-local string.
PASS " 2009-09-07T16:49 " is a correct invalid datetime-local string.
PASS "2009-09-07t16:49" is a correct invalid datetime-local string.
PASS "2009-09-07 16:49" is a correct invalid datetime-local string.
PASS "2009/09/07T16:49" is a correct invalid datetime-local string.
PASS "a" is a correct invalid datetime-local string.
PASS "-1-09-07T16:49" is a correct invalid datetime-local string.
PASS "1582-10-14T23:59:59" is a correct invalid datetime-local string.
PASS "2147483648-01-01T00:00:00" is a correct invalid datetime-local string.
PASS "0000-12-31T23:59:59.999" is a correct invalid datetime-local string.
PASS "275760-09-13T00:00:00.001" is a correct invalid datetime-local string.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS "" is a correct valid month string.
PASS "1582-10" is a correct valid month string.
PASS "0001-01" is a correct valid month string.
PASS "9999-12" is a correct valid month string.
PASS "2147483647-12" is a correct valid month string.
PASS "275760-09" is a correct valid month string.
PASS "2009-01" is a correct valid month string.
PASS "2009-02" is a correct valid month string.
PASS "2009-03" is a correct valid month string.
......@@ -22,9 +22,9 @@ PASS "2009-12" is a correct valid month string.
PASS " 2009-09 " is a correct invalid month string.
PASS "a" is a correct invalid month string.
PASS "-1-09" is a correct invalid month string.
PASS "1581-10" is a correct invalid month string.
PASS "1582-09" is a correct invalid month string.
PASS "0000-12" is a correct invalid month string.
PASS "2147483648-12" is a correct invalid month string.
PASS "275760-10" is a correct invalid month string.
PASS "2009/09" is a correct invalid month string.
PASS "200909" is a correct invalid month string.
PASS "2009--2" is a correct invalid month string.
......
......@@ -4,9 +4,10 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS "" is a correct valid week string.
PASS "0001-W01" is a correct valid week string.
PASS "1583-W01" is a correct valid week string.
PASS "9999-W52" is a correct valid week string.
PASS "2147483647-W52" is a correct valid week string.
PASS "275760-W37" is a correct valid week string.
PASS "2009-W01" is a correct valid week string.
PASS "2004-W53" is a correct valid week string.
PASS "2003-W52" is a correct valid week string.
......@@ -18,8 +19,9 @@ PASS "2009-W1" is a correct invalid week string.
PASS "2009-W001" is a correct invalid week string.
PASS "a" is a correct invalid week string.
PASS "-1-W09" is a correct invalid week string.
PASS "1582-W52" is a correct invalid week string.
PASS "0000-W52" is a correct invalid week string.
PASS "2147483648-W01" is a correct invalid week string.
PASS "275760-W38" is a correct invalid week string.
PASS "2009-W00" is a correct invalid week string.
PASS "2009-W-1" is a correct invalid week string.
PASS "2004-W54" is a correct invalid week string.
......
......@@ -11,8 +11,9 @@ PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12-01"
PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01-01"
PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12-31"
PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01-01"
PASS setValueAsDateAndGetValue(794, 9, 22) is ""
PASS setValueAsDateAndGetValue(1582, 8, 30) is ""
PASS setValueAsDateAndGetValue(-1, 0, 1) is ""
PASS setValueAsDateAndGetValue(0, 11, 31) is ""
PASS setValueAsDateAndGetValue(1, 0, 1) is "0001-01-01"
PASS setValueAsDateAndGetValue(1582, 9, 15) is "1582-10-15"
PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10-31"
PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09-13"
......
......@@ -11,9 +11,9 @@ PASS setValueAsDateAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00Z"
PASS setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100Z"
PASS setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999Z"
PASS setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01Z"
PASS setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
PASS setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
PASS setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z"
PASS setValueAsDateAndGetValue(-1, 9, 22, 0, 0, 0, 0) is ""
PASS setValueAsDateAndGetValue(0, 11, 31, 23, 59, 59, 999) is ""
PASS setValueAsDateAndGetValue(1, 0, 1, 0, 0, 0, 0) is "0001-01-01T00:00Z"
PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z"
PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1) is ""
Invalid objects:
......
......@@ -11,10 +11,10 @@ PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12"
PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01"
PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12"
PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01"
PASS setValueAsDateAndGetValue(794, 9, 22) is ""
PASS setValueAsDateAndGetValue(1582, 8, 30) is ""
PASS setValueAsDateAndGetValue(1582, 9, 1) is "1582-10"
PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10"
PASS setValueAsDateAndGetValue(-1, 9, 22) is ""
PASS setValueAsDateAndGetValue(0, 11, 30) is ""
PASS setValueAsDateAndGetValue(0001, 0, 1) is "0001-01"
PASS setValueAsDateAndGetValue(0001, 0, 31) is "0001-01"
PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09"
PASS setValueAsDateAndGetValue(275760, 8, 14) is ""
Sets null to valueAsDate:
......
......@@ -12,6 +12,7 @@ PASS valueAsDateFor("2010-W01").getTime() is Date.UTC(2010, 0, 4)
PASS valueAsDateFor("2005-W01").getTime() is Date.UTC(2005, 0, 3)
PASS valueAsDateFor("2006-W01").getTime() is Date.UTC(2006, 0, 2)
Various January 1st:
PASS setValueAsDateAndGetValue(1, 0, 1) is "0001-W01"
PASS setValueAsDateAndGetValue(2007, 0, 1) is "2007-W01"
PASS setValueAsDateAndGetValue(2008, 0, 1) is "2008-W01"
PASS setValueAsDateAndGetValue(2003, 0, 1) is "2003-W01"
......@@ -26,13 +27,9 @@ PASS setValueAsDateAndGetValue(2010, 0, 10) is "2010-W01"
PASS setValueAsDateAndGetValue(2010, 0, 11) is "2010-W02"
PASS setValueAsDateAndGetValue(2010, 0, 17) is "2010-W02"
PASS setValueAsDateAndGetValue(2010, 11, 31) is "2010-W52"
Around Gregorian calendar starting year:
PASS setValueAsDateAndGetValue(1582, 9, 14) is ""
PASS setValueAsDateAndGetValue(1582, 9, 15) is ""
PASS setValueAsDateAndGetValue(1582, 11, 31) is ""
PASS setValueAsDateAndGetValue(1583, 0, 1) is ""
PASS setValueAsDateAndGetValue(1583, 0, 2) is ""
PASS setValueAsDateAndGetValue(1583, 0, 3) is "1583-W01"
Around the minimum value:
PASS setValueAsDateAndGetValue(0, 11, 31) is ""
PASS setValueAsDateAndGetValue(0, 0, 1) is ""
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -11,10 +11,9 @@ PASS setValueAsNumberAndGetValue(1969, 11, 1) is "1969-12-01"
PASS setValueAsNumberAndGetValue(1970, 0, 1) is "1970-01-01"
PASS setValueAsNumberAndGetValue(2009, 11, 31) is "2009-12-31"
PASS setValueAsNumberAndGetValue(10000, 0, 1) is "10000-01-01"
PASS setValueAsNumberAndGetValue(794, 9, 22) is ""
PASS setValueAsNumberAndGetValue(1582, 8, 30) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 15) is "1582-10-15"
PASS setValueAsNumberAndGetValue(1582, 9, 31) is "1582-10-31"
PASS setValueAsNumberAndGetValue(-1, 0, 1) is ""
PASS setValueAsNumberAndGetValue(0, 11, 31) is ""
PASS setValueAsNumberAndGetValue(1, 0, 1) is "0001-01-01"
PASS setValueAsNumberAndGetValue(275760, 8, 13) is "275760-09-13"
Tests to set invalid values to valueAsNumber:
PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01-01"
......@@ -24,6 +23,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Date.UTC(275760, 8, 14) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -11,9 +11,9 @@ PASS setValueAsNumberAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00Z"
PASS setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100Z"
PASS setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999Z"
PASS setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01Z"
PASS setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z"
PASS setValueAsNumberAndGetValue(-1, 0, 1, 0, 0, 0, 0) is ""
PASS setValueAsNumberAndGetValue(0, 11, 31, 23, 59, 59, 999) is ""
PASS setValueAsNumberAndGetValue(1, 0, 1, 0, 0, 0, 0) is "0001-01-01T00:00Z"
PASS setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1) is "275760-09-12T00:00:00.001Z"
PASS setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z"
Tests to set invalid values to valueAsNumber:
......@@ -24,6 +24,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
Step attribute value and string representation:
PASS input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00Z"
PASS input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00.000Z"
......
......@@ -11,9 +11,10 @@ PASS setValueAsNumberAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00"
PASS setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100"
PASS setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999"
PASS setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01"
PASS setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00"
PASS setValueAsNumberAndGetValue(-1, 0, 1, 0, 0, 0, 0) is ""
PASS setValueAsNumberAndGetValue(0, 11, 31, 23, 59, 59, 999) is ""
PASS setValueAsNumberAndGetValue(1, 0, 1, 0, 0, 0, 0) is "0001-01-01T00:00"
PASS setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1) is "275760-09-12T00:00:00.001"
PASS setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00"
Tests to set invalid values to valueAsNumber:
PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01-01T00:00"
......@@ -23,6 +24,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
Step attribute value and string representation:
PASS input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00"
PASS input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00:00.000"
......
......@@ -14,12 +14,12 @@ PASS input.valueAsNumber = -1; input.value is "1969-12"
PASS input.valueAsNumber = 0; input.value is "1970-01"
PASS setValueAsNumberAndGetValue(2009, 12) is "2009-12"
PASS setValueAsNumberAndGetValue(10000, 1) is "10000-01"
PASS setValueAsNumberAndGetValue(794, 9) is ""
PASS setValueAsNumberAndGetValue(1582, 9) is ""
PASS setValueAsNumberAndGetValue(1582, 10) is "1582-10"
PASS setValueAsNumberAndGetValue(1582, 11) is "1582-11"
PASS setValueAsNumberAndGetValue(-1, 1) is ""
PASS setValueAsNumberAndGetValue(0, 12) is ""
PASS setValueAsNumberAndGetValue(1, 1) is "0001-01"
PASS setValueAsNumberAndGetValue(1, 2) is "0001-02"
PASS setValueAsNumberAndGetValue(275760, 9) is "275760-09"
PASS setValueAsNumberAndGetValue(2147483647, 12) is "2147483647-12"
PASS setValueAsNumberAndGetValue(275760, 10) is ""
Tests to set invalid values to valueAsNumber:
PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01"
PASS input.valueAsNumber = "foo" threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
......
......@@ -26,13 +26,11 @@ PASS setValueAsNumberAndGetValue(2010, 0, 10) is "2010-W01"
PASS setValueAsNumberAndGetValue(2010, 0, 11) is "2010-W02"
PASS setValueAsNumberAndGetValue(2010, 0, 17) is "2010-W02"
PASS setValueAsNumberAndGetValue(2010, 11, 31) is "2010-W52"
Around Gregorian calendar starting year:
PASS setValueAsNumberAndGetValue(1582, 9, 14) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 15) is ""
PASS setValueAsNumberAndGetValue(1582, 11, 31) is ""
PASS setValueAsNumberAndGetValue(1583, 0, 1) is ""
PASS setValueAsNumberAndGetValue(1583, 0, 2) is ""
PASS setValueAsNumberAndGetValue(1583, 0, 3) is "1583-W01"
Around the minimum/maximum values:
PASS setValueAsNumberAndGetValue(0, 11, 31) is ""
PASS setValueAsNumberAndGetValue(1, 0, 1) is "0001-W01"
PASS setValueAsNumberAndGetValue(275760, 8, 8) is "275760-W37"
PASS setValueAsNumberAndGetValue(275760, 8, 13) is "275760-W37"
Tests to set invalid values to valueAsNumber:
PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-W01"
PASS input.valueAsNumber = "foo" threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
......@@ -41,6 +39,7 @@ PASS input.valueAsNumber = Number.NaN threw exception Error: NOT_SUPPORTED_ERR:
PASS input.valueAsNumber = Infinity threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS input.valueAsNumber = Date.UTC(275760, 8, 14) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -48,7 +48,7 @@ checkNotOverflow('2010-01-27', '2010-01-27');
checkNotOverflow('2010-01-27', '2010-01-28');
checkNotOverflow('2010-01-27', '2011-01-26');
checkNotOverflow('foo', '2011-01-26');
checkNotOverflow('2010-01-27', '1000-01-01'); // Too small max value.
checkNotOverflow('2010-01-27', '0000-01-01'); // Too small max value.
// Overflow cases
checkOverflow('2010-01-27', '2010-01-26');
......@@ -69,7 +69,7 @@ checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34Z');
checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34:56Z');
checkNotOverflow('2010-01-27T12:34Z', '2011-01-26T12:34Z');
checkNotOverflow('foo', '2011-01-26T12:34Z');
checkNotOverflow('2010-01-27T12:34Z', '1000-01-01T00:00Z'); // Too small max value.
checkNotOverflow('2010-01-27T12:34Z', '0000-01-01T00:00Z'); // Too small max value.
// Overflow cases
checkOverflow('2010-01-27T12:34Z', '2010-01-26T12:33:59.999Z');
......@@ -90,7 +90,7 @@ checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34');
checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34:56');
checkNotOverflow('2010-01-27T12:34', '2011-01-26T12:34');
checkNotOverflow('foo', '2011-01-26T12:34');
checkNotOverflow('2010-01-27T12:34', '1000-01-01T00:00'); // Too small max value.
checkNotOverflow('2010-01-27T12:34', '0000-01-01T00:00'); // Too small max value.
// Overflow cases
checkOverflow('2010-01-27T12:34', '2010-01-26T12:33:59.999');
......@@ -111,7 +111,7 @@ checkNotOverflow('2010-01', '2010-01');
checkNotOverflow('2010-01', '2010-02');
checkNotOverflow('2010-01', '2011-01');
checkNotOverflow('foo', '2011-01');
checkNotOverflow('2010-01', '1000-01'); // Too small max value.
checkNotOverflow('2010-01', '0000-01'); // Too small max value.
// Overflow cases
checkOverflow('2010-01', '2009-12');
......@@ -175,9 +175,10 @@ checkNotOverflow('2010-W01', '2010-W01');
checkNotOverflow('2010-W01', '2010-W02');
checkNotOverflow('2010-W01', '2011-W01');
checkNotOverflow('foo', '2011-W01');
checkNotOverflow('2010-W01', '1582-W01'); // Too small max value.
checkNotOverflow('2010-W01', '0000-W01'); // Invalid max value.
// Overflow cases
checkOverflow('2010-W01', '1582-W01');
checkOverflow('2010-W01', '2009-W12');
checkOverflow('9999-W01', '2010-W12');
input.min = '2010-W02'; // value < min && value > max
......
......@@ -52,8 +52,10 @@ shouldBeTrue('stepMismatchFor("2010-02-09T12:34:55Z", "0.333", "2010-02-09T12:34
shouldBeFalse('stepMismatchFor("2010-02-09T12:34:55.001Z", "0.333", "2010-02-09T12:34:56Z")');
shouldBeFalse('stepMismatchFor("2010-02-09T12:34Z", "86400", "2010-02-08T12:34Z")');
shouldBeTrue('stepMismatchFor("2010-02-09T12:34:56Z", "86400", "2010-02-08T12:34Z")');
shouldBeTrue('stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-13T23:50:50Z")');
shouldBeFalse('stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-13T23:50:50Z")');
shouldBeTrue('stepMismatchFor("275760-09-13T00:00Z", "3", "275760-09-12T23:59:50Z")');
shouldBeFalse('stepMismatchFor("275760-09-13T00:00Z", "2", "275760-09-12T23:59:50Z")');
shouldBeTrue('stepMismatchFor("0001-01-01T00:00Z", "3", "0001-01-11T00:00:02Z")');
shouldBeFalse('stepMismatchFor("0001-01-01T00:00Z", "2", "0001-01-11T00:00:02Z")');
debug('Implicit step base');
shouldBeFalse('stepMismatchFor("1970-01-01T12:34Z", "120", null)');
shouldBeTrue('stepMismatchFor("1970-01-01T12:35Z", "120", null)');
......@@ -82,8 +84,10 @@ shouldBeTrue('stepMismatchFor("2010-02-09T12:34:55", "0.333", "2010-02-09T12:34:
shouldBeFalse('stepMismatchFor("2010-02-09T12:34:55.001", "0.333", "2010-02-09T12:34:56")');
shouldBeFalse('stepMismatchFor("2010-02-09T12:34", "86400", "2010-02-08T12:34")');
shouldBeTrue('stepMismatchFor("2010-02-09T12:34:56", "86400", "2010-02-08T12:34")');
shouldBeTrue('stepMismatchFor("275760-09-13T00:00", "3", "275760-09-13T23:50:50")');
shouldBeFalse('stepMismatchFor("275760-09-13T00:00", "2", "275760-09-13T23:50:50")');
shouldBeTrue('stepMismatchFor("275760-09-13T00:00", "3", "275760-09-12T23:59:50")');
shouldBeFalse('stepMismatchFor("275760-09-13T00:00", "2", "275760-09-12T23:59:50")');
shouldBeTrue('stepMismatchFor("0001-01-01T00:00", "3", "0001-01-11T00:00:02")');
shouldBeFalse('stepMismatchFor("0001-01-01T00:00", "2", "0001-01-11T00:00:02")');
debug('Implicit step base');
shouldBeFalse('stepMismatchFor("1970-01-01T12:34", "120", null)');
shouldBeTrue('stepMismatchFor("1970-01-01T12:35", "120", null)');
......
......@@ -28,8 +28,9 @@ function shouldBeInvalid(value)
shouldBeValid('');
shouldBeValid('2009-09-07');
shouldBeValid('9999-12-31');
shouldBeValid('2147483647-12-31');
shouldBeValid('275760-09-13');
shouldBeValid('1582-10-15');
shouldBeValid('0001-01-01');
shouldBeValid('2009-01-31');
shouldBeValid('2009-02-28');
shouldBeValid('2009-03-31');
......@@ -49,15 +50,15 @@ shouldBeValid('2000-02-29');
shouldBeInvalid(' 2009-09-07 ');
shouldBeInvalid('a');
shouldBeInvalid('-1-09-07');
shouldBeInvalid('1581-09-07');
shouldBeInvalid('1582-10-14');
shouldBeInvalid('0000-12-31');
shouldBeInvalid('0000-01-01');
shouldBeInvalid('275760-09-14');
shouldBeInvalid('2147483648-12-31');
shouldBeInvalid('2009/09/07');
shouldBeInvalid('20090907');
shouldBeInvalid('2009--2-07');
shouldBeInvalid('2009-00-07');
shouldBeInvalid('2009-13-07');
shouldBeInvalid('1582-09-30');
shouldBeInvalid('2009-xx-30');
shouldBeInvalid('2009-01-32');
shouldBeInvalid('2009-02-29');
......
......@@ -32,11 +32,12 @@ shouldBeValid('2009-09-07T16:49:31.1Z');
shouldBeValid('2009-09-07T16:49:31.12Z');
shouldBeValid('2009-09-07T16:49:31.123Z');
shouldBeValid('2009-09-07T16:49:31.1234567890Z');
shouldBeValid('2147483647-12-31T23:59:59.999Z');
shouldBeValid('1582-10-15T00:00:00.000Z');
shouldBeValid('1582-10-15T00:00:00.000+00:00');
shouldBeValid('1582-10-15T01:30+01:30');
shouldBeValid('1582-10-15T00:00+01:00');
shouldBeValid('275760-09-12T23:59:59.999Z');
shouldBeValid('275760-09-13T00:00:00.000Z');
shouldBeValid('0001-01-01T00:00:00.000Z');
shouldBeValid('0001-01-01T00:00:00.000+00:00');
shouldBeValid('0001-01-01T01:30+01:30');
shouldBeValid('0001-01-01T00:00+01:00');
// Invalid values
shouldBeInvalid(' 2009-09-07T16:49Z ');
......@@ -54,7 +55,7 @@ shouldBeInvalid('2009-09-07T16:49-23');
shouldBeInvalid('2009-09-07T16:49-23:');
shouldBeInvalid('2009-09-07T16:49-24:00');
shouldBeInvalid('2009-09-07T16:49-23:60');
shouldBeInvalid('1582-10-14T23:59:59Z');
shouldBeInvalid('0000-12-31T23:59:59Z');
shouldBeInvalid('2147483647-12-31T23:59-00:01');
shouldBeInvalid('2147483648-01-01T00:00:00Z');
......
......@@ -32,8 +32,8 @@ shouldBeValid('2009-09-07T16:49:31.1');
shouldBeValid('2009-09-07T16:49:31.12');
shouldBeValid('2009-09-07T16:49:31.123');
shouldBeValid('2009-09-07T16:49:31.1234567890');
shouldBeValid('2147483647-12-31T23:59:59.999');
shouldBeValid('1582-10-15T00:00:00.000');
shouldBeValid('275760-09-13T00:00:00.000');
shouldBeValid('0001-01-01T00:00:00.000');
// Invalid values
shouldBeInvalid(' 2009-09-07T16:49 ');
......@@ -42,7 +42,7 @@ shouldBeInvalid('2009-09-07 16:49');
shouldBeInvalid('2009/09/07T16:49');
shouldBeInvalid('a');
shouldBeInvalid('-1-09-07T16:49');
shouldBeInvalid('1582-10-14T23:59:59');
shouldBeInvalid('2147483648-01-01T00:00:00');
shouldBeInvalid('0000-12-31T23:59:59.999');
shouldBeInvalid('275760-09-13T00:00:00.001');
var successfullyParsed = true;
......@@ -26,9 +26,9 @@ function shouldBeInvalid(value)
// Valid values
shouldBeValid('');
shouldBeValid('1582-10');
shouldBeValid('0001-01');
shouldBeValid('9999-12');
shouldBeValid('2147483647-12');
shouldBeValid('275760-09');
shouldBeValid('2009-01');
shouldBeValid('2009-02');
shouldBeValid('2009-03');
......@@ -46,9 +46,9 @@ shouldBeValid('2009-12');
shouldBeInvalid(' 2009-09 ');
shouldBeInvalid('a');
shouldBeInvalid('-1-09');
shouldBeInvalid('1581-10');
shouldBeInvalid('1582-09');
shouldBeInvalid('0000-12');
shouldBeInvalid('2147483648-12');
shouldBeInvalid('275760-10');
shouldBeInvalid('2009/09');
shouldBeInvalid('200909');
shouldBeInvalid('2009--2');
......
......@@ -26,9 +26,10 @@ function shouldBeInvalid(value)
// Valid values
shouldBeValid('');
shouldBeValid('0001-W01');
shouldBeValid('1583-W01');
shouldBeValid('9999-W52');
shouldBeValid('2147483647-W52');
shouldBeValid('275760-W37');
shouldBeValid('2009-W01');
shouldBeValid('2004-W53'); // 2004 started on Thursday.
shouldBeValid('2003-W52'); // 2003 started on Wednesday, but wasn't a leap year.
......@@ -42,8 +43,9 @@ shouldBeInvalid('2009-W1');
shouldBeInvalid('2009-W001');
shouldBeInvalid('a');
shouldBeInvalid('-1-W09');
shouldBeInvalid('1582-W52');
shouldBeInvalid('0000-W52');
shouldBeInvalid('2147483648-W01');
shouldBeInvalid('275760-W38');
shouldBeInvalid('2009-W00');
shouldBeInvalid('2009-W-1');
shouldBeInvalid('2004-W54'); // 2004 started on Thursday.
......
......@@ -11,6 +11,8 @@ function valueAsDateFor(stringValue) {
function setValueAsDateAndGetValue(year, month, day) {
var date = new Date();
date.setTime(Date.UTC(year, month, day));
if (year < 100)
date.setUTCFullYear(year);
input.valueAsDate = date;
return input.value;
}
......@@ -25,8 +27,9 @@ shouldBe('setValueAsDateAndGetValue(1970, 0, 1)', '"1970-01-01"');
shouldBe('setValueAsDateAndGetValue(2009, 11, 31)', '"2009-12-31"');
shouldBe('setValueAsDateAndGetValue(10000, 0, 1)', '"10000-01-01"');
shouldBe('setValueAsDateAndGetValue(794, 9, 22)', '""');
shouldBe('setValueAsDateAndGetValue(1582, 8, 30)', '""');
shouldBe('setValueAsDateAndGetValue(-1, 0, 1)', '""');
shouldBe('setValueAsDateAndGetValue(0, 11, 31)', '""');
shouldBe('setValueAsDateAndGetValue(1, 0, 1)', '"0001-01-01"');
shouldBe('setValueAsDateAndGetValue(1582, 9, 15)', '"1582-10-15"');
shouldBe('setValueAsDateAndGetValue(1582, 9, 31)', '"1582-10-31"');
shouldBe('setValueAsDateAndGetValue(275760, 8, 13)', '"275760-09-13"');
......
......@@ -11,6 +11,8 @@ function valueAsDateFor(stringValue) {
function setValueAsDateAndGetValue(year, month, day, hour, minute, second, msec) {
var date = new Date();
date.setTime(Date.UTC(year, month, day, hour, minute, second, msec));
if (year < 100)
date.setUTCFullYear(year);