Changeset 266170 in webkit
- Timestamp:
- Aug 26, 2020 9:48:33 AM (9 months ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/intl-datetimeformat.js (modified) (1 diff)
-
JSTests/test262/config.yaml (modified) (1 diff)
-
JSTests/test262/expectations.yaml (modified) (2 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/builtins/DatePrototype.js (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/CommonIdentifiers.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp (modified) (7 diffs)
-
Source/JavaScriptCore/runtime/IntlDateTimeFormat.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r266164 r266170 1 2020-08-26 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement Intl.DateTimeFormat fractionalSecondDigits 4 https://bugs.webkit.org/show_bug.cgi?id=215840 5 6 Reviewed by Ross Kirsling. 7 8 Test262 is showing wrong ordering of option property accesses compared to the latest PR. 9 Later, we should update Test262. 10 11 * stress/intl-datetimeformat.js: 12 (const.options.get second): 13 (const.options.get fractionalSecondDigits): 14 (const.options.get localeMatcher): 15 (const.options.get timeZoneName): 16 (const.options.get formatMatcher): 17 * test262/config.yaml: 18 * test262/expectations.yaml: 19 1 20 2020-08-26 Paulo Matos <pmatos@igalia.com> 2 21 -
trunk/JSTests/stress/intl-datetimeformat.js
r266039 r266170 661 661 shouldBe(JSON.stringify(Intl.DateTimeFormat('zh-u-ca-chinese', { era: 'short', year: 'numeric' }).formatToParts(0)), parts); 662 662 shouldBe(JSON.stringify(Intl.DateTimeFormat('zh', { era: 'short', year: 'numeric', calendar: 'chinese' }).formatToParts(0)), parts); 663 664 { 665 let t = new Date("2019-05-20T07:00:23.123"); 666 { 667 let dtf = new Intl.DateTimeFormat("en", {hour: "numeric", minute: "numeric", second: "numeric", fractionalSecondDigits: 3}); 668 shouldBe(dtf.format(t), `7:00:23.123 AM`); 669 let expected = [ 670 {type: "hour", value: "7"}, 671 {type: "literal", value: ":"}, 672 {type: "minute", value: "00"}, 673 {type: "literal", value: ":"}, 674 {type: "second", value: "23"}, 675 {type: "literal", value: "."}, 676 {type: "fractionalSecond", value: "123"}, 677 {type: "literal", value: " "}, 678 {type: "dayPeriod", value: "AM"} 679 ]; 680 let actual = dtf.formatToParts(t); 681 shouldBe(actual.length, expected.length); 682 for (let index = 0; index < expected.length; ++index) { 683 shouldBe(actual[index].type, expected[index].type); 684 shouldBe(actual[index].value, expected[index].value); 685 } 686 } 687 { 688 let dtf = new Intl.DateTimeFormat("en", {hour: "numeric", minute: "numeric", second: "numeric", fractionalSecondDigits: 2}); 689 shouldBe(dtf.format(t), `7:00:23.12 AM`); 690 } 691 { 692 let dtf = new Intl.DateTimeFormat("en", {hour: "numeric", minute: "numeric", second: "numeric", fractionalSecondDigits: 1}); 693 shouldBe(dtf.format(t), `7:00:23.1 AM`); 694 shouldBe(JSON.stringify(dtf.resolvedOptions()), `{"locale":"en","calendar":"gregory","numberingSystem":"latn","timeZone":"America/Los_Angeles","hourCycle":"h12","hour12":true,"hour":"numeric","minute":"2-digit","second":"2-digit","fractionalSecondDigits":1}`); 695 } 696 shouldThrow(() => { 697 new Intl.DateTimeFormat("en", {hour: "numeric", minute: "numeric", second: "numeric", fractionalSecondDigits: 0}); 698 }, RangeError); 699 shouldThrow(() => { 700 new Intl.DateTimeFormat("en", {hour: "numeric", minute: "numeric", second: "numeric", fractionalSecondDigits: 4}); 701 }, RangeError); 702 } 703 { 704 const expected = [ 705 "second", 706 "fractionalSecondDigits", 707 "localeMatcher", 708 "second", 709 "fractionalSecondDigits", 710 "timeZoneName", 711 "formatMatcher", 712 ]; 713 714 const actual = []; 715 716 const options = { 717 get second() { 718 actual.push("second"); 719 return "numeric"; 720 }, 721 get fractionalSecondDigits() { 722 actual.push("fractionalSecondDigits"); 723 return undefined; 724 }, 725 get localeMatcher() { 726 actual.push("localeMatcher"); 727 return undefined; 728 }, 729 get timeZoneName() { 730 actual.push("timeZoneName"); 731 return undefined; 732 }, 733 get formatMatcher() { 734 actual.push("formatMatcher"); 735 return undefined; 736 }, 737 }; 738 739 new Intl.DateTimeFormat("en", options); 740 shouldBe(JSON.stringify(actual), JSON.stringify(expected)); 741 } 742 { 743 shouldBe(new Date(0).toLocaleTimeString('zh-Hans-CN', { timeZone: 'UTC', numberingSystem: 'hanidec', hour: "numeric", minute: "numeric", second: "numeric", fractionalSecondDigits: 2 }), "上午一二:〇〇:〇〇.〇〇"); 744 } -
trunk/JSTests/test262/config.yaml
r266035 r266170 26 26 - top-level-await 27 27 - Intl.DateTimeFormat-dayPeriod 28 - Intl.DateTimeFormat-fractionalSecondDigits29 28 - Intl.ListFormat 30 29 paths: -
trunk/JSTests/test262/expectations.yaml
r266117 r266170 1552 1552 default: "Test262Error: \"kn-true\" is returned in locale, but shouldn't be. Expected SameValue(«7», «-1») to be true" 1553 1553 strict mode: "Test262Error: \"kn-true\" is returned in locale, but shouldn't be. Expected SameValue(«7», «-1») to be true" 1554 test/intl402/DateTimeFormat/constructor-options-order-fractionalSecondDigits.js: 1555 default: 'Test262Error: Expected [second, fractionalSecondDigits, localeMatcher, second, fractionalSecondDigits, timeZoneName, formatMatcher] and [second, fractionalSecondDigits, localeMatcher, second, timeZoneName, fractionalSecondDigits, formatMatcher] to have the same contents. ' 1556 strict mode: 'Test262Error: Expected [second, fractionalSecondDigits, localeMatcher, second, fractionalSecondDigits, timeZoneName, formatMatcher] and [second, fractionalSecondDigits, localeMatcher, second, timeZoneName, fractionalSecondDigits, formatMatcher] to have the same contents. ' 1554 1557 test/intl402/DateTimeFormat/prototype/format/timedatestyle-en.js: 1555 1558 default: 'Test262Error: Result for full with {} Expected SameValue(«14:12:47 PM Coordinated Universal Time», «14:12:47 Coordinated Universal Time») to be true' … … 1558 1561 default: 'Test262Error: Expected SameValue(«1/3/2019 – 1/5/2019», «1/3/2019 – 1/5/2019») to be true' 1559 1562 strict mode: 'Test262Error: Expected SameValue(«1/3/2019 – 1/5/2019», «1/3/2019 – 1/5/2019») to be true' 1563 test/intl402/DateTimeFormat/prototype/formatRange/fractionalSecondDigits.js: 1564 default: 'Test262Error: no fractionalSecondDigits Expected SameValue(«02:03 – 02:13», «02:03 – 02:13») to be true' 1565 strict mode: 'Test262Error: no fractionalSecondDigits Expected SameValue(«02:03 – 02:13», «02:03 – 02:13») to be true' 1560 1566 test/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js: 1561 1567 default: 'Test262Error: Expected SameValue(«h24», «h23») to be true' -
trunk/Source/JavaScriptCore/ChangeLog
r266159 r266170 1 2020-08-26 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement Intl.DateTimeFormat fractionalSecondDigits 4 https://bugs.webkit.org/show_bug.cgi?id=215840 5 6 Reviewed by Ross Kirsling. 7 8 This patch implements fractionalSecondDigits option for Intl.DateTimeFormat. If it is 9 specified, milliseconds in N digits are represented in the formatted output. 10 This extension is about to be merged into the spec[1]. SpiderMonkey and V8 support it, 11 and V8 shipped it without flags. 12 13 [1]: https://github.com/tc39/ecma402/pull/347 14 15 * builtins/DatePrototype.js: 16 (toLocaleString.toDateTimeOptionsAnyAll): 17 (toLocaleString): 18 (toLocaleTimeString.toDateTimeOptionsTimeTime): 19 (toLocaleTimeString): 20 * runtime/CommonIdentifiers.h: 21 * runtime/IntlDateTimeFormat.cpp: 22 (JSC::toDateTimeOptionsAnyDate): 23 (JSC::IntlDateTimeFormat::setFormatsFromPattern): 24 (JSC::IntlDateTimeFormat::initializeDateTimeFormat): 25 (JSC::IntlDateTimeFormat::resolvedOptions const): 26 (JSC::partTypeString): 27 * runtime/IntlDateTimeFormat.h: 28 1 29 2020-08-25 Yusuke Suzuki <ysuzuki@apple.com> 2 30 -
trunk/Source/JavaScriptCore/builtins/DatePrototype.js
r266035 r266170 49 49 options.hour === @undefined && 50 50 options.minute === @undefined && 51 options.second === @undefined 51 options.second === @undefined && 52 options.fractionalSecondDigits === @undefined 52 53 ); 53 54 … … 164 165 options.hour === @undefined && 165 166 options.minute === @undefined && 166 options.second === @undefined 167 options.second === @undefined && 168 options.fractionalSecondDigits === @undefined 167 169 ); 168 170 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r266035 r266170 117 117 macro(formatToParts) \ 118 118 macro(forward) \ 119 macro(fractionalSecondDigits) \ 119 120 macro(from) \ 120 121 macro(fromCharCode) \ -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
r266035 r266170 249 249 // Always "any". 250 250 251 // a. For each of the property names "hour", "minute", "second" :251 // a. For each of the property names "hour", "minute", "second", "fractionalSecondDigits": 252 252 // i. Let prop be the property name. 253 253 // ii. Let value be Get(options, prop). … … 267 267 RETURN_IF_EXCEPTION(scope, nullptr); 268 268 if (!second.isUndefined()) 269 needDefaults = false; 270 271 JSValue fractionalSecondDigits = options->get(globalObject, vm.propertyNames->fractionalSecondDigits); 272 RETURN_IF_EXCEPTION(scope, nullptr); 273 if (!fractionalSecondDigits.isUndefined()) 269 274 needDefaults = false; 270 275 … … 403 408 m_timeZoneName = TimeZoneName::Long; 404 409 break; 410 case 'S': 411 m_fractionalSecondDigits = count; 412 break; 405 413 } 406 414 } … … 626 634 } 627 635 636 unsigned fractionalSecondDigits = intlNumberOption(globalObject, options, vm.propertyNames->fractionalSecondDigits, 1, 3, 0); 637 RETURN_IF_EXCEPTION(scope, void()); 638 for (unsigned i = 0; i < fractionalSecondDigits; ++i) 639 skeletonBuilder.append('S'); 640 628 641 TimeZoneName timeZoneName = intlOption<TimeZoneName>(globalObject, options, vm.propertyNames->timeZoneName, { { "short"_s, TimeZoneName::Short }, { "long"_s, TimeZoneName::Long } }, "timeZoneName must be \"short\" or \"long\""_s, TimeZoneName::None); 629 642 RETURN_IF_EXCEPTION(scope, void()); … … 656 669 // iii. If p is not undefined, then 657 670 // 1. Throw a TypeError exception. 658 if (weekday != Weekday::None || era != Era::None || year != Year::None || month != Month::None || day != Day::None || hour != Hour::None || minute != Minute::None || second != Second::None || timeZoneName != TimeZoneName::None) {671 if (weekday != Weekday::None || era != Era::None || year != Year::None || month != Month::None || day != Day::None || hour != Hour::None || minute != Minute::None || second != Second::None || fractionalSecondDigits != 0 || timeZoneName != TimeZoneName::None) { 659 672 throwTypeError(globalObject, scope, "dateStyle and timeStyle may not be used with other DateTimeFormat options"_s); 660 673 return; … … 999 1012 options->putDirect(vm, vm.propertyNames->second, jsNontrivialString(vm, secondString(m_second))); 1000 1013 1014 if (m_fractionalSecondDigits) 1015 options->putDirect(vm, vm.propertyNames->fractionalSecondDigits, jsNumber(m_fractionalSecondDigits)); 1016 1001 1017 if (m_timeZoneName != TimeZoneName::None) 1002 1018 options->putDirect(vm, vm.propertyNames->timeZoneName, jsNontrivialString(vm, timeZoneNameString(m_timeZoneName))); … … 1053 1069 return "minute"_s; 1054 1070 case UDAT_SECOND_FIELD: 1071 return "second"_s; 1055 1072 case UDAT_FRACTIONAL_SECOND_FIELD: 1056 return " second"_s;1073 return "fractionalSecond"_s; 1057 1074 case UDAT_DAY_OF_WEEK_FIELD: 1058 1075 case UDAT_DOW_LOCAL_FIELD: -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
r266035 r266170 121 121 Minute m_minute { Minute::None }; 122 122 Second m_second { Second::None }; 123 uint8_t m_fractionalSecondDigits { 0 }; 123 124 TimeZoneName m_timeZoneName { TimeZoneName::None }; 124 125 DateTimeStyle m_dateStyle { DateTimeStyle::None };
Note: See TracChangeset
for help on using the changeset viewer.