| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ECMAScript 402 API implementation. | 5 // ECMAScript 402 API implementation. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Intl object is a single object that has some named properties, | 8 * Intl object is a single object that has some named properties, |
| 9 * all of which are constructors. | 9 * all of which are constructors. |
| 10 */ | 10 */ |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 %IncrementUseCounter(kIntlResolved); | 905 %IncrementUseCounter(kIntlResolved); |
| 906 return this[resolvedSymbol]; | 906 return this[resolvedSymbol]; |
| 907 }, | 907 }, |
| 908 set(value) { | 908 set(value) { |
| 909 this[resolvedSymbol] = value; | 909 this[resolvedSymbol] = value; |
| 910 } | 910 } |
| 911 }; | 911 }; |
| 912 | 912 |
| 913 // ECMA 402 section 8.2.1 | 913 // ECMA 402 section 8.2.1 |
| 914 InstallFunction(Intl, 'getCanonicalLocales', function(locales) { | 914 InstallFunction(Intl, 'getCanonicalLocales', function(locales) { |
| 915 if (!IS_UNDEFINED(new.target)) { | |
| 916 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 917 } | |
| 918 | |
| 919 return makeArray(canonicalizeLocaleList(locales)); | 915 return makeArray(canonicalizeLocaleList(locales)); |
| 920 } | 916 } |
| 921 ); | 917 ); |
| 922 | 918 |
| 923 /** | 919 /** |
| 924 * Initializes the given object so it's a valid Collator instance. | 920 * Initializes the given object so it's a valid Collator instance. |
| 925 * Useful for subclassing. | 921 * Useful for subclassing. |
| 926 */ | 922 */ |
| 927 function initializeCollator(collator, locales, options) { | 923 function initializeCollator(collator, locales, options) { |
| 928 if (%IsInitializedIntlObject(collator)) { | 924 if (%IsInitializedIntlObject(collator)) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 | 1040 |
| 1045 return initializeCollator(TO_OBJECT(this), locales, options); | 1041 return initializeCollator(TO_OBJECT(this), locales, options); |
| 1046 } | 1042 } |
| 1047 ); | 1043 ); |
| 1048 | 1044 |
| 1049 | 1045 |
| 1050 /** | 1046 /** |
| 1051 * Collator resolvedOptions method. | 1047 * Collator resolvedOptions method. |
| 1052 */ | 1048 */ |
| 1053 InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() { | 1049 InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() { |
| 1054 if (!IS_UNDEFINED(new.target)) { | |
| 1055 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1056 } | |
| 1057 | |
| 1058 if (!%IsInitializedIntlObjectOfType(this, 'collator')) { | 1050 if (!%IsInitializedIntlObjectOfType(this, 'collator')) { |
| 1059 throw %make_type_error(kResolvedOptionsCalledOnNonObject, "Collator"); | 1051 throw %make_type_error(kResolvedOptionsCalledOnNonObject, "Collator"); |
| 1060 } | 1052 } |
| 1061 | 1053 |
| 1062 var coll = this; | 1054 var coll = this; |
| 1063 var locale = getOptimalLanguageTag(coll[resolvedSymbol].requestedLocale, | 1055 var locale = getOptimalLanguageTag(coll[resolvedSymbol].requestedLocale, |
| 1064 coll[resolvedSymbol].locale); | 1056 coll[resolvedSymbol].locale); |
| 1065 | 1057 |
| 1066 return { | 1058 return { |
| 1067 locale: locale, | 1059 locale: locale, |
| 1068 usage: coll[resolvedSymbol].usage, | 1060 usage: coll[resolvedSymbol].usage, |
| 1069 sensitivity: coll[resolvedSymbol].sensitivity, | 1061 sensitivity: coll[resolvedSymbol].sensitivity, |
| 1070 ignorePunctuation: coll[resolvedSymbol].ignorePunctuation, | 1062 ignorePunctuation: coll[resolvedSymbol].ignorePunctuation, |
| 1071 numeric: coll[resolvedSymbol].numeric, | 1063 numeric: coll[resolvedSymbol].numeric, |
| 1072 caseFirst: coll[resolvedSymbol].caseFirst, | 1064 caseFirst: coll[resolvedSymbol].caseFirst, |
| 1073 collation: coll[resolvedSymbol].collation | 1065 collation: coll[resolvedSymbol].collation |
| 1074 }; | 1066 }; |
| 1075 } | 1067 } |
| 1076 ); | 1068 ); |
| 1077 | 1069 |
| 1078 | 1070 |
| 1079 /** | 1071 /** |
| 1080 * Returns the subset of the given locale list for which this locale list | 1072 * Returns the subset of the given locale list for which this locale list |
| 1081 * has a matching (possibly fallback) locale. Locales appear in the same | 1073 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1082 * order in the returned list as in the input list. | 1074 * order in the returned list as in the input list. |
| 1083 * Options are optional parameter. | 1075 * Options are optional parameter. |
| 1084 */ | 1076 */ |
| 1085 InstallFunction(Intl.Collator, 'supportedLocalesOf', function(locales) { | 1077 InstallFunction(Intl.Collator, 'supportedLocalesOf', function(locales) { |
| 1086 if (!IS_UNDEFINED(new.target)) { | |
| 1087 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1088 } | |
| 1089 | |
| 1090 return supportedLocalesOf('collator', locales, arguments[1]); | 1078 return supportedLocalesOf('collator', locales, arguments[1]); |
| 1091 } | 1079 } |
| 1092 ); | 1080 ); |
| 1093 | 1081 |
| 1094 | 1082 |
| 1095 /** | 1083 /** |
| 1096 * When the compare method is called with two arguments x and y, it returns a | 1084 * When the compare method is called with two arguments x and y, it returns a |
| 1097 * Number other than NaN that represents the result of a locale-sensitive | 1085 * Number other than NaN that represents the result of a locale-sensitive |
| 1098 * String comparison of x with y. | 1086 * String comparison of x with y. |
| 1099 * The result is intended to order String values in the sort order specified | 1087 * The result is intended to order String values in the sort order specified |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 | 1273 |
| 1286 return initializeNumberFormat(TO_OBJECT(this), locales, options); | 1274 return initializeNumberFormat(TO_OBJECT(this), locales, options); |
| 1287 } | 1275 } |
| 1288 ); | 1276 ); |
| 1289 | 1277 |
| 1290 | 1278 |
| 1291 /** | 1279 /** |
| 1292 * NumberFormat resolvedOptions method. | 1280 * NumberFormat resolvedOptions method. |
| 1293 */ | 1281 */ |
| 1294 InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() { | 1282 InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() { |
| 1295 if (!IS_UNDEFINED(new.target)) { | |
| 1296 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1297 } | |
| 1298 | |
| 1299 if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) { | 1283 if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) { |
| 1300 throw %make_type_error(kResolvedOptionsCalledOnNonObject, "NumberFormat"); | 1284 throw %make_type_error(kResolvedOptionsCalledOnNonObject, "NumberFormat"); |
| 1301 } | 1285 } |
| 1302 | 1286 |
| 1303 var format = this; | 1287 var format = this; |
| 1304 var locale = getOptimalLanguageTag(format[resolvedSymbol].requestedLocale, | 1288 var locale = getOptimalLanguageTag(format[resolvedSymbol].requestedLocale, |
| 1305 format[resolvedSymbol].locale); | 1289 format[resolvedSymbol].locale); |
| 1306 | 1290 |
| 1307 var result = { | 1291 var result = { |
| 1308 locale: locale, | 1292 locale: locale, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1335 ); | 1319 ); |
| 1336 | 1320 |
| 1337 | 1321 |
| 1338 /** | 1322 /** |
| 1339 * Returns the subset of the given locale list for which this locale list | 1323 * Returns the subset of the given locale list for which this locale list |
| 1340 * has a matching (possibly fallback) locale. Locales appear in the same | 1324 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1341 * order in the returned list as in the input list. | 1325 * order in the returned list as in the input list. |
| 1342 * Options are optional parameter. | 1326 * Options are optional parameter. |
| 1343 */ | 1327 */ |
| 1344 InstallFunction(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { | 1328 InstallFunction(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { |
| 1345 if (!IS_UNDEFINED(new.target)) { | |
| 1346 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1347 } | |
| 1348 | |
| 1349 return supportedLocalesOf('numberformat', locales, arguments[1]); | 1329 return supportedLocalesOf('numberformat', locales, arguments[1]); |
| 1350 } | 1330 } |
| 1351 ); | 1331 ); |
| 1352 | 1332 |
| 1353 | 1333 |
| 1354 /** | 1334 /** |
| 1355 * Returns a String value representing the result of calling ToNumber(value) | 1335 * Returns a String value representing the result of calling ToNumber(value) |
| 1356 * according to the effective locale and the formatting options of this | 1336 * according to the effective locale and the formatting options of this |
| 1357 * NumberFormat. | 1337 * NumberFormat. |
| 1358 */ | 1338 */ |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 | 1649 |
| 1670 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); | 1650 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); |
| 1671 } | 1651 } |
| 1672 ); | 1652 ); |
| 1673 | 1653 |
| 1674 | 1654 |
| 1675 /** | 1655 /** |
| 1676 * DateTimeFormat resolvedOptions method. | 1656 * DateTimeFormat resolvedOptions method. |
| 1677 */ | 1657 */ |
| 1678 InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { | 1658 InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { |
| 1679 if (!IS_UNDEFINED(new.target)) { | |
| 1680 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1681 } | |
| 1682 | |
| 1683 if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) { | 1659 if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) { |
| 1684 throw %make_type_error(kResolvedOptionsCalledOnNonObject, "DateTimeFormat"
); | 1660 throw %make_type_error(kResolvedOptionsCalledOnNonObject, "DateTimeFormat"
); |
| 1685 } | 1661 } |
| 1686 | 1662 |
| 1687 /** | 1663 /** |
| 1688 * Maps ICU calendar names to LDML/BCP47 types for key 'ca'. | 1664 * Maps ICU calendar names to LDML/BCP47 types for key 'ca'. |
| 1689 * See typeMap section in third_party/icu/source/data/misc/keyTypeData.txt | 1665 * See typeMap section in third_party/icu/source/data/misc/keyTypeData.txt |
| 1690 * and | 1666 * and |
| 1691 * http://www.unicode.org/repos/cldr/tags/latest/common/bcp47/calendar.xml | 1667 * http://www.unicode.org/repos/cldr/tags/latest/common/bcp47/calendar.xml |
| 1692 */ | 1668 */ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 ); | 1705 ); |
| 1730 | 1706 |
| 1731 | 1707 |
| 1732 /** | 1708 /** |
| 1733 * Returns the subset of the given locale list for which this locale list | 1709 * Returns the subset of the given locale list for which this locale list |
| 1734 * has a matching (possibly fallback) locale. Locales appear in the same | 1710 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1735 * order in the returned list as in the input list. | 1711 * order in the returned list as in the input list. |
| 1736 * Options are optional parameter. | 1712 * Options are optional parameter. |
| 1737 */ | 1713 */ |
| 1738 InstallFunction(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { | 1714 InstallFunction(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { |
| 1739 if (!IS_UNDEFINED(new.target)) { | |
| 1740 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1741 } | |
| 1742 | |
| 1743 return supportedLocalesOf('dateformat', locales, arguments[1]); | 1715 return supportedLocalesOf('dateformat', locales, arguments[1]); |
| 1744 } | 1716 } |
| 1745 ); | 1717 ); |
| 1746 | 1718 |
| 1747 | 1719 |
| 1748 /** | 1720 /** |
| 1749 * Returns a String value representing the result of calling ToNumber(date) | 1721 * Returns a String value representing the result of calling ToNumber(date) |
| 1750 * according to the effective locale and the formatting options of this | 1722 * according to the effective locale and the formatting options of this |
| 1751 * DateTimeFormat. | 1723 * DateTimeFormat. |
| 1752 */ | 1724 */ |
| 1753 function formatDate(formatter, dateValue) { | 1725 function formatDate(formatter, dateValue) { |
| 1754 var dateMs; | 1726 var dateMs; |
| 1755 if (IS_UNDEFINED(dateValue)) { | 1727 if (IS_UNDEFINED(dateValue)) { |
| 1756 dateMs = %DateCurrentTime(); | 1728 dateMs = %DateCurrentTime(); |
| 1757 } else { | 1729 } else { |
| 1758 dateMs = TO_NUMBER(dateValue); | 1730 dateMs = TO_NUMBER(dateValue); |
| 1759 } | 1731 } |
| 1760 | 1732 |
| 1761 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); | 1733 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); |
| 1762 | 1734 |
| 1763 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), | 1735 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), |
| 1764 new GlobalDate(dateMs)); | 1736 new GlobalDate(dateMs)); |
| 1765 } | 1737 } |
| 1766 | 1738 |
| 1767 function FormatDateToParts(dateValue) { | 1739 function FormatDateToParts(dateValue) { |
| 1768 if (!IS_UNDEFINED(new.target)) { | |
| 1769 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 1770 } | |
| 1771 CHECK_OBJECT_COERCIBLE(this, "Intl.DateTimeFormat.prototype.formatToParts"); | 1740 CHECK_OBJECT_COERCIBLE(this, "Intl.DateTimeFormat.prototype.formatToParts"); |
| 1772 if (!IS_OBJECT(this)) { | 1741 if (!IS_OBJECT(this)) { |
| 1773 throw %make_type_error(kCalledOnNonObject, this); | 1742 throw %make_type_error(kCalledOnNonObject, this); |
| 1774 } | 1743 } |
| 1775 var dateMs; | 1744 var dateMs; |
| 1776 if (IS_UNDEFINED(dateValue)) { | 1745 if (IS_UNDEFINED(dateValue)) { |
| 1777 dateMs = %DateCurrentTime(); | 1746 dateMs = %DateCurrentTime(); |
| 1778 } else { | 1747 } else { |
| 1779 dateMs = TO_NUMBER(dateValue); | 1748 dateMs = TO_NUMBER(dateValue); |
| 1780 } | 1749 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 } | 2037 } |
| 2069 return %StringLocaleConvertCase(s, isToUpper, | 2038 return %StringLocaleConvertCase(s, isToUpper, |
| 2070 CUSTOM_CASE_LANGUAGES[langIndex]); | 2039 CUSTOM_CASE_LANGUAGES[langIndex]); |
| 2071 } | 2040 } |
| 2072 | 2041 |
| 2073 /** | 2042 /** |
| 2074 * Compares this and that, and returns less than 0, 0 or greater than 0 value. | 2043 * Compares this and that, and returns less than 0, 0 or greater than 0 value. |
| 2075 * Overrides the built-in method. | 2044 * Overrides the built-in method. |
| 2076 */ | 2045 */ |
| 2077 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { | 2046 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { |
| 2078 if (!IS_UNDEFINED(new.target)) { | |
| 2079 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 2080 } | |
| 2081 | |
| 2082 if (IS_NULL_OR_UNDEFINED(this)) { | 2047 if (IS_NULL_OR_UNDEFINED(this)) { |
| 2083 throw %make_type_error(kMethodInvokedOnNullOrUndefined); | 2048 throw %make_type_error(kMethodInvokedOnNullOrUndefined); |
| 2084 } | 2049 } |
| 2085 | 2050 |
| 2086 var locales = arguments[1]; | 2051 var locales = arguments[1]; |
| 2087 var options = arguments[2]; | 2052 var options = arguments[2]; |
| 2088 var collator = cachedOrNewService('collator', locales, options); | 2053 var collator = cachedOrNewService('collator', locales, options); |
| 2089 return compare(collator, this, that); | 2054 return compare(collator, this, that); |
| 2090 } | 2055 } |
| 2091 ); | 2056 ); |
| 2092 | 2057 |
| 2093 | 2058 |
| 2094 /** | 2059 /** |
| 2095 * Unicode normalization. This method is called with one argument that | 2060 * Unicode normalization. This method is called with one argument that |
| 2096 * specifies the normalization form. | 2061 * specifies the normalization form. |
| 2097 * If none is specified, "NFC" is assumed. | 2062 * If none is specified, "NFC" is assumed. |
| 2098 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw | 2063 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
| 2099 * a RangeError Exception. | 2064 * a RangeError Exception. |
| 2100 */ | 2065 */ |
| 2101 | 2066 |
| 2102 OverrideFunction(GlobalString.prototype, 'normalize', function() { | 2067 OverrideFunction(GlobalString.prototype, 'normalize', function() { |
| 2103 if (!IS_UNDEFINED(new.target)) { | |
| 2104 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 2105 } | |
| 2106 | |
| 2107 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 2068 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
| 2108 var s = TO_STRING(this); | 2069 var s = TO_STRING(this); |
| 2109 | 2070 |
| 2110 var formArg = arguments[0]; | 2071 var formArg = arguments[0]; |
| 2111 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); | 2072 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); |
| 2112 | 2073 |
| 2113 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | 2074 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
| 2114 | 2075 |
| 2115 var normalizationForm = %ArrayIndexOf(NORMALIZATION_FORMS, form, 0); | 2076 var normalizationForm = %ArrayIndexOf(NORMALIZATION_FORMS, form, 0); |
| 2116 if (normalizationForm === -1) { | 2077 if (normalizationForm === -1) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 to.ToLocaleLowerCaseI18N = ToLocaleLowerCaseI18N; | 2118 to.ToLocaleLowerCaseI18N = ToLocaleLowerCaseI18N; |
| 2158 to.ToLocaleUpperCaseI18N = ToLocaleUpperCaseI18N; | 2119 to.ToLocaleUpperCaseI18N = ToLocaleUpperCaseI18N; |
| 2159 }); | 2120 }); |
| 2160 | 2121 |
| 2161 | 2122 |
| 2162 /** | 2123 /** |
| 2163 * Formats a Number object (this) using locale and options values. | 2124 * Formats a Number object (this) using locale and options values. |
| 2164 * If locale or options are omitted, defaults are used. | 2125 * If locale or options are omitted, defaults are used. |
| 2165 */ | 2126 */ |
| 2166 OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { | 2127 OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { |
| 2167 if (!IS_UNDEFINED(new.target)) { | |
| 2168 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 2169 } | |
| 2170 | |
| 2171 if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') { | 2128 if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') { |
| 2172 throw %make_type_error(kMethodInvokedOnWrongType, "Number"); | 2129 throw %make_type_error(kMethodInvokedOnWrongType, "Number"); |
| 2173 } | 2130 } |
| 2174 | 2131 |
| 2175 var locales = arguments[0]; | 2132 var locales = arguments[0]; |
| 2176 var options = arguments[1]; | 2133 var options = arguments[1]; |
| 2177 var numberFormat = cachedOrNewService('numberformat', locales, options); | 2134 var numberFormat = cachedOrNewService('numberformat', locales, options); |
| 2178 return formatNumber(numberFormat, this); | 2135 return formatNumber(numberFormat, this); |
| 2179 } | 2136 } |
| 2180 ); | 2137 ); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2199 return formatDate(dateFormat, date); | 2156 return formatDate(dateFormat, date); |
| 2200 } | 2157 } |
| 2201 | 2158 |
| 2202 | 2159 |
| 2203 /** | 2160 /** |
| 2204 * Formats a Date object (this) using locale and options values. | 2161 * Formats a Date object (this) using locale and options values. |
| 2205 * If locale or options are omitted, defaults are used - both date and time are | 2162 * If locale or options are omitted, defaults are used - both date and time are |
| 2206 * present in the output. | 2163 * present in the output. |
| 2207 */ | 2164 */ |
| 2208 OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() { | 2165 OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() { |
| 2209 if (!IS_UNDEFINED(new.target)) { | |
| 2210 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 2211 } | |
| 2212 | |
| 2213 var locales = arguments[0]; | 2166 var locales = arguments[0]; |
| 2214 var options = arguments[1]; | 2167 var options = arguments[1]; |
| 2215 return toLocaleDateTime( | 2168 return toLocaleDateTime( |
| 2216 this, locales, options, 'any', 'all', 'dateformatall'); | 2169 this, locales, options, 'any', 'all', 'dateformatall'); |
| 2217 } | 2170 } |
| 2218 ); | 2171 ); |
| 2219 | 2172 |
| 2220 | 2173 |
| 2221 /** | 2174 /** |
| 2222 * Formats a Date object (this) using locale and options values. | 2175 * Formats a Date object (this) using locale and options values. |
| 2223 * If locale or options are omitted, defaults are used - only date is present | 2176 * If locale or options are omitted, defaults are used - only date is present |
| 2224 * in the output. | 2177 * in the output. |
| 2225 */ | 2178 */ |
| 2226 OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { | 2179 OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { |
| 2227 if (!IS_UNDEFINED(new.target)) { | |
| 2228 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 2229 } | |
| 2230 | |
| 2231 var locales = arguments[0]; | 2180 var locales = arguments[0]; |
| 2232 var options = arguments[1]; | 2181 var options = arguments[1]; |
| 2233 return toLocaleDateTime( | 2182 return toLocaleDateTime( |
| 2234 this, locales, options, 'date', 'date', 'dateformatdate'); | 2183 this, locales, options, 'date', 'date', 'dateformatdate'); |
| 2235 } | 2184 } |
| 2236 ); | 2185 ); |
| 2237 | 2186 |
| 2238 | 2187 |
| 2239 /** | 2188 /** |
| 2240 * Formats a Date object (this) using locale and options values. | 2189 * Formats a Date object (this) using locale and options values. |
| 2241 * If locale or options are omitted, defaults are used - only time is present | 2190 * If locale or options are omitted, defaults are used - only time is present |
| 2242 * in the output. | 2191 * in the output. |
| 2243 */ | 2192 */ |
| 2244 OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { | 2193 OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { |
| 2245 if (!IS_UNDEFINED(new.target)) { | |
| 2246 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
| 2247 } | |
| 2248 | |
| 2249 var locales = arguments[0]; | 2194 var locales = arguments[0]; |
| 2250 var options = arguments[1]; | 2195 var options = arguments[1]; |
| 2251 return toLocaleDateTime( | 2196 return toLocaleDateTime( |
| 2252 this, locales, options, 'time', 'time', 'dateformattime'); | 2197 this, locales, options, 'time', 'time', 'dateformattime'); |
| 2253 } | 2198 } |
| 2254 ); | 2199 ); |
| 2255 | 2200 |
| 2256 %FunctionRemovePrototype(FormatDateToParts); | 2201 %FunctionRemovePrototype(FormatDateToParts); |
| 2257 | 2202 |
| 2258 utils.Export(function(to) { | 2203 utils.Export(function(to) { |
| 2259 to.FormatDateToParts = FormatDateToParts; | 2204 to.FormatDateToParts = FormatDateToParts; |
| 2260 }); | 2205 }); |
| 2261 | 2206 |
| 2262 }) | 2207 }) |
| OLD | NEW |