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 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1790 } else { | 1790 } else { |
1791 dateMs = TO_NUMBER(dateValue); | 1791 dateMs = TO_NUMBER(dateValue); |
1792 } | 1792 } |
1793 | 1793 |
1794 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); | 1794 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); |
1795 | 1795 |
1796 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), | 1796 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), |
1797 new GlobalDate(dateMs)); | 1797 new GlobalDate(dateMs)); |
1798 } | 1798 } |
1799 | 1799 |
1800 function formatDateToParts(dateValue) { | |
Dan Ehrenberg
2016/09/06 19:39:29
Nit: rename to FormatDateToParts
jungshik at Google
2016/09/06 21:35:14
Done.
| |
1801 if (!IS_UNDEFINED(new.target)) { | |
1802 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | |
1803 } | |
1804 CHECK_OBJECT_COERCIBLE(this, "Intl.DateTimeFormat.prototype.formatToParts"); | |
1805 if (!IS_OBJECT(this)) { | |
1806 throw %make_type_error(kCalledOnNonObject, this); | |
1807 } | |
1808 var dateMs; | |
1809 if (IS_UNDEFINED(dateValue)) { | |
1810 dateMs = %DateCurrentTime(); | |
1811 } else { | |
1812 dateMs = TO_NUMBER(dateValue); | |
1813 } | |
1814 | |
1815 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); | |
1816 | |
1817 return %InternalDateFormatToParts( | |
1818 %GetImplFromInitializedIntlObject(this), new GlobalDate(dateMs)); | |
1819 } | |
1820 | |
1821 %FunctionSetLength(formatDateToParts, 0); | |
1822 | |
1800 | 1823 |
1801 /** | 1824 /** |
1802 * Returns a Date object representing the result of calling ToString(value) | 1825 * Returns a Date object representing the result of calling ToString(value) |
1803 * according to the effective locale and the formatting options of this | 1826 * according to the effective locale and the formatting options of this |
1804 * DateTimeFormat. | 1827 * DateTimeFormat. |
1805 * Returns undefined if date string cannot be parsed. | 1828 * Returns undefined if date string cannot be parsed. |
1806 */ | 1829 */ |
1807 function IntlParseDate(formatter, value) { | 1830 function IntlParseDate(formatter, value) { |
1808 return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter), | 1831 return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter), |
1809 TO_STRING(value)); | 1832 TO_STRING(value)); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2284 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); | 2307 throw %make_type_error(kOrdinaryFunctionCalledAsConstructor); |
2285 } | 2308 } |
2286 | 2309 |
2287 var locales = arguments[0]; | 2310 var locales = arguments[0]; |
2288 var options = arguments[1]; | 2311 var options = arguments[1]; |
2289 return toLocaleDateTime( | 2312 return toLocaleDateTime( |
2290 this, locales, options, 'time', 'time', 'dateformattime'); | 2313 this, locales, options, 'time', 'time', 'dateformattime'); |
2291 } | 2314 } |
2292 ); | 2315 ); |
2293 | 2316 |
2317 %FunctionRemovePrototype(formatDateToParts); | |
2318 | |
2294 utils.Export(function(to) { | 2319 utils.Export(function(to) { |
2295 to.AddBoundMethod = AddBoundMethod; | 2320 to.AddBoundMethod = AddBoundMethod; |
2321 to.formatDateToParts = formatDateToParts; | |
2296 to.IntlParseDate = IntlParseDate; | 2322 to.IntlParseDate = IntlParseDate; |
2297 to.IntlParseNumber = IntlParseNumber; | 2323 to.IntlParseNumber = IntlParseNumber; |
2298 }); | 2324 }); |
2299 | 2325 |
2300 }) | 2326 }) |
OLD | NEW |