Changeset 53669 in webkit
- Timestamp:
- Jan 21, 2010 7:29:30 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r53664 r53669 1 2010-01-21 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 HTMLInputElement::valueAsDate setter support for type=datetime. 6 https://bugs.webkit.org/show_bug.cgi?id=33939 7 8 Add setter tests to input-valueasdate-datetime.js, and update the 9 expectation. 10 11 Note: the expectation file contains some FAIL lines. They are 12 intentional because they test a unimplemented feature. 13 14 * fast/forms/input-valueasdate-datetime-expected.txt: 15 * fast/forms/script-tests/input-valueasdate-datetime.js: 16 1 17 2010-01-21 Shinichiro Hamaji <hamaji@chromium.org> 2 18 -
trunk/LayoutTests/fast/forms/input-valueasdate-datetime-expected.txt
r52524 r53669 8 8 PASS valueAsDateFor("1970-01-01T00:00:00.000Z").getTime() is Date.UTC(1970, 0, 1, 0, 0, 0) 9 9 PASS valueAsDateFor("2009-12-22T11:32:11Z").getTime() is Date.UTC(2009, 11, 22, 11, 32, 11) 10 PASS setValueAsDateAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00Z" 11 PASS setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100Z" 12 PASS setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999Z" 13 PASS setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01Z" 14 PASS setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0) is "" 15 PASS setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999) is "" 16 PASS setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z" 17 PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z" 18 PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1) is "" 19 Invalid objects: 20 PASS input.value = "2010-01-01T00:00Z"; input.valueAsDate = document; input.value is "" 21 PASS input.value = "2010-01-01T00:00Z"; input.valueAsDate = null; input.value is "" 22 Step attribute value and string representation: 23 FAIL input.step = "1"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0) should be 2010-01-21T00:00:00. Was 2010-01-21T00:00Z. 24 FAIL input.step = "0.001"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0) should be 2010-01-21T00:00:00.000. Was 2010-01-21T00:00Z. 10 25 PASS successfullyParsed is true 11 26 -
trunk/LayoutTests/fast/forms/script-tests/input-valueasdate-datetime.js
r52524 r53669 9 9 } 10 10 11 function setValueAsDateAndGetValue(year, month, day, hour, minute, second, msec) { 12 var date = new Date(); 13 date.setTime(Date.UTC(year, month, day, hour, minute, second, msec)); 14 input.valueAsDate = date; 15 return input.value; 16 } 17 11 18 shouldBe('valueAsDateFor("")', 'null'); 12 19 shouldBe('valueAsDateFor("1969-12-31T12:34:56.789Z").getTime()', 'Date.UTC(1969, 11, 31, 12, 34, 56, 789)'); … … 14 21 shouldBe('valueAsDateFor("2009-12-22T11:32:11Z").getTime()', 'Date.UTC(2009, 11, 22, 11, 32, 11)'); 15 22 23 shouldBe('setValueAsDateAndGetValue(1969, 11, 1, 0, 0, 0, 0)', '"1969-12-01T00:00Z"'); 24 shouldBe('setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T10:01:00.100Z"'); 25 shouldBe('setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999)', '"2009-12-31T23:59:59.999Z"'); 26 shouldBe('setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T12:00:01Z"'); 27 28 shouldBe('setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0)', '""'); 29 shouldBe('setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999)', '""'); 30 shouldBe('setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0)', '"1582-10-15T00:00Z"'); 31 shouldBe('setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0)', '"275760-09-13T00:00Z"'); 32 shouldBe('setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1)', '""'); // Date of JavaScript can't represent this. 33 34 debug('Invalid objects:'); 35 shouldBe('input.value = "2010-01-01T00:00Z"; input.valueAsDate = document; input.value', '""'); 36 shouldBe('input.value = "2010-01-01T00:00Z"; input.valueAsDate = null; input.value', '""'); 37 38 debug('Step attribute value and string representation:'); 39 // If the step attribute value is 1 second and the second part is 0, we should show the second part. 40 shouldBe('input.step = "1"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00:00"'); 41 // If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part. 42 shouldBe('input.step = "0.001"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00:00.000"'); 43 16 44 var successfullyParsed = true; -
trunk/WebCore/ChangeLog
r53668 r53669 1 2010-01-21 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 HTMLInputElement::valueAsDate setter support for type=datetime. 6 https://bugs.webkit.org/show_bug.cgi?id=33939 7 8 Introduce ISODateTime::setMillisecondsSinceEpochForDateTime() and add 9 DateTime type support to ISODateTime::toString(). 10 11 * html/HTMLInputElement.cpp: 12 (WebCore::HTMLInputElement::setValueAsDate): 13 * html/ISODateTime.cpp: 14 (WebCore::ISODateTime::setMillisecondsSinceEpochForDate): 15 Set Invalid to m_type. 16 (WebCore::ISODateTime::setMillisecondsSinceEpochForDateTime): 17 (WebCore::ISODateTime::setMillisecondsSinceEpochForMonth): 18 Set Invalid to m_type. 19 (WebCore::ISODateTime::setMillisecondsSinceMidnight): 20 Set Invalid to m_type. 21 (WebCore::ISODateTime::toString): 22 Support DateTime type. This always produces UTC representation. 23 * html/ISODateTime.h: 24 1 25 2010-01-21 Geoffrey Garen <ggaren@apple.com> 2 26 -
trunk/WebCore/html/HTMLInputElement.cpp
r53598 r53669 1401 1401 case DATE: 1402 1402 success = dateTime.setMillisecondsSinceEpochForDate(value); 1403 break; 1404 case DATETIME: 1405 success = dateTime.setMillisecondsSinceEpochForDateTime(value); 1403 1406 break; 1404 1407 case MONTH: -
trunk/WebCore/html/ISODateTime.cpp
r53598 r53669 479 479 bool ISODateTime::setMillisecondsSinceEpochForDate(double ms) 480 480 { 481 m_type = Invalid; 481 482 if (!isfinite(ms)) 482 483 return false; 484 if (!setMillisecondsSinceEpochForDateInternal(round(ms))) 485 return false; 486 if (beforeGregorianStartDate(m_year, m_month, m_monthDay)) 487 return false; 488 m_type = Date; 489 return true; 490 } 491 492 bool ISODateTime::setMillisecondsSinceEpochForDateTime(double ms) 493 { 494 m_type = Invalid; 495 if (!isfinite(ms)) 496 return false; 497 ms = round(ms); 498 setMillisecondsSinceMidnightInternal(positiveFmod(ms, msPerDay)); 483 499 if (!setMillisecondsSinceEpochForDateInternal(ms)) 484 500 return false; 485 501 if (beforeGregorianStartDate(m_year, m_month, m_monthDay)) 486 502 return false; 487 m_type = Date ;503 m_type = DateTime; 488 504 return true; 489 505 } … … 491 507 bool ISODateTime::setMillisecondsSinceEpochForMonth(double ms) 492 508 { 509 m_type = Invalid; 493 510 if (!isfinite(ms)) 494 511 return false; 495 if (!setMillisecondsSinceEpochForDateInternal( ms))512 if (!setMillisecondsSinceEpochForDateInternal(round(ms))) 496 513 return false; 497 514 // Ignore m_monthDay updated by setMillisecondsSinceEpochForDateInternal(). … … 504 521 bool ISODateTime::setMillisecondsSinceMidnight(double ms) 505 522 { 523 m_type = Invalid; 506 524 if (!isfinite(ms)) 507 525 return false; … … 571 589 case Date: 572 590 return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay); 591 case DateTime: 592 return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay) 593 + toStringForTime(format) + String("Z"); 573 594 case Month: 574 595 return String::format("%04d-%02d", m_year, m_month + 1); -
trunk/WebCore/html/ISODateTime.h
r53598 r53669 79 79 String toString(SecondFormat format = None) const; 80 80 81 // parse*() and setMillisecondsSince*() functions are initializers for an 82 // ISODateTime instance. If these functions return false, the instance 83 // might be invalid. 84 81 85 // The following six functions parse the input 'src' whose length is 82 86 // 'length', and updates some fields of this instance. The parsing starts at … … 109 113 // For Date type. Updates m_year, m_month and m_monthDay. 110 114 bool setMillisecondsSinceEpochForDate(double ms); 115 // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond. 116 bool setMillisecondsSinceEpochForDateTime(double ms); 111 117 // For Month type. Updates m_year and m_month. 112 118 bool setMillisecondsSinceEpochForMonth(double ms);
Note: See TracChangeset
for help on using the changeset viewer.