| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return implementation(that, x); | 225 return implementation(that, x); |
| 226 } | 226 } |
| 227 } else { | 227 } else { |
| 228 boundMethod = function() { | 228 boundMethod = function() { |
| 229 if (!IS_UNDEFINED(new.target)) { | 229 if (!IS_UNDEFINED(new.target)) { |
| 230 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 230 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 231 } | 231 } |
| 232 // DateTimeFormat.format needs to be 0 arg method, but can stil | 232 // DateTimeFormat.format needs to be 0 arg method, but can stil |
| 233 // receive optional dateValue param. If one was provided, pass it | 233 // receive optional dateValue param. If one was provided, pass it |
| 234 // along. | 234 // along. |
| 235 if (%_ArgumentsLength() > 0) { | 235 if (arguments.length > 0) { |
| 236 return implementation(that, %_Arguments(0)); | 236 return implementation(that, arguments[0]); |
| 237 } else { | 237 } else { |
| 238 return implementation(that); | 238 return implementation(that); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 %FunctionSetName(boundMethod, internalName); | 242 %FunctionSetName(boundMethod, internalName); |
| 243 %FunctionRemovePrototype(boundMethod); | 243 %FunctionRemovePrototype(boundMethod); |
| 244 %SetNativeFlag(boundMethod); | 244 %SetNativeFlag(boundMethod); |
| 245 this[internalName] = boundMethod; | 245 this[internalName] = boundMethod; |
| 246 } | 246 } |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 } | 995 } |
| 996 | 996 |
| 997 | 997 |
| 998 /** | 998 /** |
| 999 * Constructs Intl.Collator object given optional locales and options | 999 * Constructs Intl.Collator object given optional locales and options |
| 1000 * parameters. | 1000 * parameters. |
| 1001 * | 1001 * |
| 1002 * @constructor | 1002 * @constructor |
| 1003 */ | 1003 */ |
| 1004 %AddNamedProperty(Intl, 'Collator', function() { | 1004 %AddNamedProperty(Intl, 'Collator', function() { |
| 1005 var locales = %_Arguments(0); | 1005 var locales = arguments[0]; |
| 1006 var options = %_Arguments(1); | 1006 var options = arguments[1]; |
| 1007 | 1007 |
| 1008 if (!this || this === Intl) { | 1008 if (!this || this === Intl) { |
| 1009 // Constructor is called as a function. | 1009 // Constructor is called as a function. |
| 1010 return new Intl.Collator(locales, options); | 1010 return new Intl.Collator(locales, options); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 return initializeCollator(TO_OBJECT(this), locales, options); | 1013 return initializeCollator(TO_OBJECT(this), locales, options); |
| 1014 }, | 1014 }, |
| 1015 DONT_ENUM | 1015 DONT_ENUM |
| 1016 ); | 1016 ); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 * Returns the subset of the given locale list for which this locale list | 1053 * Returns the subset of the given locale list for which this locale list |
| 1054 * has a matching (possibly fallback) locale. Locales appear in the same | 1054 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1055 * order in the returned list as in the input list. | 1055 * order in the returned list as in the input list. |
| 1056 * Options are optional parameter. | 1056 * Options are optional parameter. |
| 1057 */ | 1057 */ |
| 1058 %AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { | 1058 %AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { |
| 1059 if (!IS_UNDEFINED(new.target)) { | 1059 if (!IS_UNDEFINED(new.target)) { |
| 1060 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1060 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 return supportedLocalesOf('collator', locales, %_Arguments(1)); | 1063 return supportedLocalesOf('collator', locales, arguments[1]); |
| 1064 }, | 1064 }, |
| 1065 DONT_ENUM | 1065 DONT_ENUM |
| 1066 ); | 1066 ); |
| 1067 %FunctionSetName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); | 1067 %FunctionSetName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); |
| 1068 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); | 1068 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); |
| 1069 %SetNativeFlag(Intl.Collator.supportedLocalesOf); | 1069 %SetNativeFlag(Intl.Collator.supportedLocalesOf); |
| 1070 | 1070 |
| 1071 | 1071 |
| 1072 /** | 1072 /** |
| 1073 * When the compare method is called with two arguments x and y, it returns a | 1073 * When the compare method is called with two arguments x and y, it returns a |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 | 1250 |
| 1251 /** | 1251 /** |
| 1252 * Constructs Intl.NumberFormat object given optional locales and options | 1252 * Constructs Intl.NumberFormat object given optional locales and options |
| 1253 * parameters. | 1253 * parameters. |
| 1254 * | 1254 * |
| 1255 * @constructor | 1255 * @constructor |
| 1256 */ | 1256 */ |
| 1257 %AddNamedProperty(Intl, 'NumberFormat', function() { | 1257 %AddNamedProperty(Intl, 'NumberFormat', function() { |
| 1258 var locales = %_Arguments(0); | 1258 var locales = arguments[0]; |
| 1259 var options = %_Arguments(1); | 1259 var options = arguments[1]; |
| 1260 | 1260 |
| 1261 if (!this || this === Intl) { | 1261 if (!this || this === Intl) { |
| 1262 // Constructor is called as a function. | 1262 // Constructor is called as a function. |
| 1263 return new Intl.NumberFormat(locales, options); | 1263 return new Intl.NumberFormat(locales, options); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 return initializeNumberFormat(TO_OBJECT(this), locales, options); | 1266 return initializeNumberFormat(TO_OBJECT(this), locales, options); |
| 1267 }, | 1267 }, |
| 1268 DONT_ENUM | 1268 DONT_ENUM |
| 1269 ); | 1269 ); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 * Returns the subset of the given locale list for which this locale list | 1325 * Returns the subset of the given locale list for which this locale list |
| 1326 * has a matching (possibly fallback) locale. Locales appear in the same | 1326 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1327 * order in the returned list as in the input list. | 1327 * order in the returned list as in the input list. |
| 1328 * Options are optional parameter. | 1328 * Options are optional parameter. |
| 1329 */ | 1329 */ |
| 1330 %AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { | 1330 %AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { |
| 1331 if (!IS_UNDEFINED(new.target)) { | 1331 if (!IS_UNDEFINED(new.target)) { |
| 1332 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1332 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 return supportedLocalesOf('numberformat', locales, %_Arguments(1)); | 1335 return supportedLocalesOf('numberformat', locales, arguments[1]); |
| 1336 }, | 1336 }, |
| 1337 DONT_ENUM | 1337 DONT_ENUM |
| 1338 ); | 1338 ); |
| 1339 %FunctionSetName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); | 1339 %FunctionSetName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); |
| 1340 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); | 1340 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); |
| 1341 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); | 1341 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); |
| 1342 | 1342 |
| 1343 | 1343 |
| 1344 /** | 1344 /** |
| 1345 * Returns a String value representing the result of calling ToNumber(value) | 1345 * Returns a String value representing the result of calling ToNumber(value) |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 | 1654 |
| 1655 /** | 1655 /** |
| 1656 * Constructs Intl.DateTimeFormat object given optional locales and options | 1656 * Constructs Intl.DateTimeFormat object given optional locales and options |
| 1657 * parameters. | 1657 * parameters. |
| 1658 * | 1658 * |
| 1659 * @constructor | 1659 * @constructor |
| 1660 */ | 1660 */ |
| 1661 %AddNamedProperty(Intl, 'DateTimeFormat', function() { | 1661 %AddNamedProperty(Intl, 'DateTimeFormat', function() { |
| 1662 var locales = %_Arguments(0); | 1662 var locales = arguments[0]; |
| 1663 var options = %_Arguments(1); | 1663 var options = arguments[1]; |
| 1664 | 1664 |
| 1665 if (!this || this === Intl) { | 1665 if (!this || this === Intl) { |
| 1666 // Constructor is called as a function. | 1666 // Constructor is called as a function. |
| 1667 return new Intl.DateTimeFormat(locales, options); | 1667 return new Intl.DateTimeFormat(locales, options); |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); | 1670 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); |
| 1671 }, | 1671 }, |
| 1672 DONT_ENUM | 1672 DONT_ENUM |
| 1673 ); | 1673 ); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 * Returns the subset of the given locale list for which this locale list | 1748 * Returns the subset of the given locale list for which this locale list |
| 1749 * has a matching (possibly fallback) locale. Locales appear in the same | 1749 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1750 * order in the returned list as in the input list. | 1750 * order in the returned list as in the input list. |
| 1751 * Options are optional parameter. | 1751 * Options are optional parameter. |
| 1752 */ | 1752 */ |
| 1753 %AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { | 1753 %AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { |
| 1754 if (!IS_UNDEFINED(new.target)) { | 1754 if (!IS_UNDEFINED(new.target)) { |
| 1755 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1755 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1756 } | 1756 } |
| 1757 | 1757 |
| 1758 return supportedLocalesOf('dateformat', locales, %_Arguments(1)); | 1758 return supportedLocalesOf('dateformat', locales, arguments[1]); |
| 1759 }, | 1759 }, |
| 1760 DONT_ENUM | 1760 DONT_ENUM |
| 1761 ); | 1761 ); |
| 1762 %FunctionSetName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); | 1762 %FunctionSetName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); |
| 1763 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); | 1763 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); |
| 1764 %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); | 1764 %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); |
| 1765 | 1765 |
| 1766 | 1766 |
| 1767 /** | 1767 /** |
| 1768 * Returns a String value representing the result of calling ToNumber(date) | 1768 * Returns a String value representing the result of calling ToNumber(date) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 } | 1879 } |
| 1880 | 1880 |
| 1881 | 1881 |
| 1882 /** | 1882 /** |
| 1883 * Constructs Intl.v8BreakIterator object given optional locales and options | 1883 * Constructs Intl.v8BreakIterator object given optional locales and options |
| 1884 * parameters. | 1884 * parameters. |
| 1885 * | 1885 * |
| 1886 * @constructor | 1886 * @constructor |
| 1887 */ | 1887 */ |
| 1888 %AddNamedProperty(Intl, 'v8BreakIterator', function() { | 1888 %AddNamedProperty(Intl, 'v8BreakIterator', function() { |
| 1889 var locales = %_Arguments(0); | 1889 var locales = arguments[0]; |
| 1890 var options = %_Arguments(1); | 1890 var options = arguments[1]; |
| 1891 | 1891 |
| 1892 if (!this || this === Intl) { | 1892 if (!this || this === Intl) { |
| 1893 // Constructor is called as a function. | 1893 // Constructor is called as a function. |
| 1894 return new Intl.v8BreakIterator(locales, options); | 1894 return new Intl.v8BreakIterator(locales, options); |
| 1895 } | 1895 } |
| 1896 | 1896 |
| 1897 return initializeBreakIterator(TO_OBJECT(this), locales, options); | 1897 return initializeBreakIterator(TO_OBJECT(this), locales, options); |
| 1898 }, | 1898 }, |
| 1899 DONT_ENUM | 1899 DONT_ENUM |
| 1900 ); | 1900 ); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 * has a matching (possibly fallback) locale. Locales appear in the same | 1936 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1937 * order in the returned list as in the input list. | 1937 * order in the returned list as in the input list. |
| 1938 * Options are optional parameter. | 1938 * Options are optional parameter. |
| 1939 */ | 1939 */ |
| 1940 %AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf', | 1940 %AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf', |
| 1941 function(locales) { | 1941 function(locales) { |
| 1942 if (!IS_UNDEFINED(new.target)) { | 1942 if (!IS_UNDEFINED(new.target)) { |
| 1943 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1943 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1944 } | 1944 } |
| 1945 | 1945 |
| 1946 return supportedLocalesOf('breakiterator', locales, %_Arguments(1)); | 1946 return supportedLocalesOf('breakiterator', locales, arguments[1]); |
| 1947 }, | 1947 }, |
| 1948 DONT_ENUM | 1948 DONT_ENUM |
| 1949 ); | 1949 ); |
| 1950 %FunctionSetName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); | 1950 %FunctionSetName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); |
| 1951 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); | 1951 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); |
| 1952 %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); | 1952 %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); |
| 1953 | 1953 |
| 1954 | 1954 |
| 1955 /** | 1955 /** |
| 1956 * Adopts text to segment using the iterator. Old text, if present, | 1956 * Adopts text to segment using the iterator. Old text, if present, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2054 */ | 2054 */ |
| 2055 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { | 2055 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { |
| 2056 if (!IS_UNDEFINED(new.target)) { | 2056 if (!IS_UNDEFINED(new.target)) { |
| 2057 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2057 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2058 } | 2058 } |
| 2059 | 2059 |
| 2060 if (IS_NULL_OR_UNDEFINED(this)) { | 2060 if (IS_NULL_OR_UNDEFINED(this)) { |
| 2061 throw MakeTypeError(kMethodInvokedOnNullOrUndefined); | 2061 throw MakeTypeError(kMethodInvokedOnNullOrUndefined); |
| 2062 } | 2062 } |
| 2063 | 2063 |
| 2064 var locales = %_Arguments(1); | 2064 var locales = arguments[1]; |
| 2065 var options = %_Arguments(2); | 2065 var options = arguments[2]; |
| 2066 var collator = cachedOrNewService('collator', locales, options); | 2066 var collator = cachedOrNewService('collator', locales, options); |
| 2067 return compare(collator, this, that); | 2067 return compare(collator, this, that); |
| 2068 } | 2068 } |
| 2069 ); | 2069 ); |
| 2070 | 2070 |
| 2071 | 2071 |
| 2072 /** | 2072 /** |
| 2073 * Unicode normalization. This method is called with one argument that | 2073 * Unicode normalization. This method is called with one argument that |
| 2074 * specifies the normalization form. | 2074 * specifies the normalization form. |
| 2075 * If none is specified, "NFC" is assumed. | 2075 * If none is specified, "NFC" is assumed. |
| 2076 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw | 2076 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
| 2077 * a RangeError Exception. | 2077 * a RangeError Exception. |
| 2078 */ | 2078 */ |
| 2079 | 2079 |
| 2080 OverrideFunction(GlobalString.prototype, 'normalize', function() { | 2080 OverrideFunction(GlobalString.prototype, 'normalize', function() { |
| 2081 if (!IS_UNDEFINED(new.target)) { | 2081 if (!IS_UNDEFINED(new.target)) { |
| 2082 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2082 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2083 } | 2083 } |
| 2084 | 2084 |
| 2085 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 2085 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
| 2086 var s = TO_STRING(this); | 2086 var s = TO_STRING(this); |
| 2087 | 2087 |
| 2088 var formArg = %_Arguments(0); | 2088 var formArg = arguments[0]; |
| 2089 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); | 2089 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); |
| 2090 | 2090 |
| 2091 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | 2091 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
| 2092 | 2092 |
| 2093 var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); | 2093 var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); |
| 2094 if (normalizationForm === -1) { | 2094 if (normalizationForm === -1) { |
| 2095 throw MakeRangeError(kNormalizationForm, | 2095 throw MakeRangeError(kNormalizationForm, |
| 2096 %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); | 2096 %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); |
| 2097 } | 2097 } |
| 2098 | 2098 |
| 2099 return %StringNormalize(s, normalizationForm); | 2099 return %StringNormalize(s, normalizationForm); |
| 2100 } | 2100 } |
| 2101 ); | 2101 ); |
| 2102 | 2102 |
| 2103 | 2103 |
| 2104 /** | 2104 /** |
| 2105 * Formats a Number object (this) using locale and options values. | 2105 * Formats a Number object (this) using locale and options values. |
| 2106 * If locale or options are omitted, defaults are used. | 2106 * If locale or options are omitted, defaults are used. |
| 2107 */ | 2107 */ |
| 2108 OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { | 2108 OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { |
| 2109 if (!IS_UNDEFINED(new.target)) { | 2109 if (!IS_UNDEFINED(new.target)) { |
| 2110 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2110 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2111 } | 2111 } |
| 2112 | 2112 |
| 2113 if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') { | 2113 if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') { |
| 2114 throw MakeTypeError(kMethodInvokedOnWrongType, "Number"); | 2114 throw MakeTypeError(kMethodInvokedOnWrongType, "Number"); |
| 2115 } | 2115 } |
| 2116 | 2116 |
| 2117 var locales = %_Arguments(0); | 2117 var locales = arguments[0]; |
| 2118 var options = %_Arguments(1); | 2118 var options = arguments[1]; |
| 2119 var numberFormat = cachedOrNewService('numberformat', locales, options); | 2119 var numberFormat = cachedOrNewService('numberformat', locales, options); |
| 2120 return formatNumber(numberFormat, this); | 2120 return formatNumber(numberFormat, this); |
| 2121 } | 2121 } |
| 2122 ); | 2122 ); |
| 2123 | 2123 |
| 2124 | 2124 |
| 2125 /** | 2125 /** |
| 2126 * Returns actual formatted date or fails if date parameter is invalid. | 2126 * Returns actual formatted date or fails if date parameter is invalid. |
| 2127 */ | 2127 */ |
| 2128 function toLocaleDateTime(date, locales, options, required, defaults, service) { | 2128 function toLocaleDateTime(date, locales, options, required, defaults, service) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2144 /** | 2144 /** |
| 2145 * Formats a Date object (this) using locale and options values. | 2145 * Formats a Date object (this) using locale and options values. |
| 2146 * If locale or options are omitted, defaults are used - both date and time are | 2146 * If locale or options are omitted, defaults are used - both date and time are |
| 2147 * present in the output. | 2147 * present in the output. |
| 2148 */ | 2148 */ |
| 2149 OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() { | 2149 OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() { |
| 2150 if (!IS_UNDEFINED(new.target)) { | 2150 if (!IS_UNDEFINED(new.target)) { |
| 2151 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2151 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2152 } | 2152 } |
| 2153 | 2153 |
| 2154 var locales = %_Arguments(0); | 2154 var locales = arguments[0]; |
| 2155 var options = %_Arguments(1); | 2155 var options = arguments[1]; |
| 2156 return toLocaleDateTime( | 2156 return toLocaleDateTime( |
| 2157 this, locales, options, 'any', 'all', 'dateformatall'); | 2157 this, locales, options, 'any', 'all', 'dateformatall'); |
| 2158 } | 2158 } |
| 2159 ); | 2159 ); |
| 2160 | 2160 |
| 2161 | 2161 |
| 2162 /** | 2162 /** |
| 2163 * Formats a Date object (this) using locale and options values. | 2163 * Formats a Date object (this) using locale and options values. |
| 2164 * If locale or options are omitted, defaults are used - only date is present | 2164 * If locale or options are omitted, defaults are used - only date is present |
| 2165 * in the output. | 2165 * in the output. |
| 2166 */ | 2166 */ |
| 2167 OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { | 2167 OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { |
| 2168 if (!IS_UNDEFINED(new.target)) { | 2168 if (!IS_UNDEFINED(new.target)) { |
| 2169 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2169 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 var locales = %_Arguments(0); | 2172 var locales = arguments[0]; |
| 2173 var options = %_Arguments(1); | 2173 var options = arguments[1]; |
| 2174 return toLocaleDateTime( | 2174 return toLocaleDateTime( |
| 2175 this, locales, options, 'date', 'date', 'dateformatdate'); | 2175 this, locales, options, 'date', 'date', 'dateformatdate'); |
| 2176 } | 2176 } |
| 2177 ); | 2177 ); |
| 2178 | 2178 |
| 2179 | 2179 |
| 2180 /** | 2180 /** |
| 2181 * Formats a Date object (this) using locale and options values. | 2181 * Formats a Date object (this) using locale and options values. |
| 2182 * If locale or options are omitted, defaults are used - only time is present | 2182 * If locale or options are omitted, defaults are used - only time is present |
| 2183 * in the output. | 2183 * in the output. |
| 2184 */ | 2184 */ |
| 2185 OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { | 2185 OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { |
| 2186 if (!IS_UNDEFINED(new.target)) { | 2186 if (!IS_UNDEFINED(new.target)) { |
| 2187 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2187 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 var locales = %_Arguments(0); | 2190 var locales = arguments[0]; |
| 2191 var options = %_Arguments(1); | 2191 var options = arguments[1]; |
| 2192 return toLocaleDateTime( | 2192 return toLocaleDateTime( |
| 2193 this, locales, options, 'time', 'time', 'dateformattime'); | 2193 this, locales, options, 'time', 'time', 'dateformattime'); |
| 2194 } | 2194 } |
| 2195 ); | 2195 ); |
| 2196 | 2196 |
| 2197 }) | 2197 }) |
| OLD | NEW |