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 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1792 } else { | 1792 } else { |
1793 dateMs = TO_NUMBER(dateValue); | 1793 dateMs = TO_NUMBER(dateValue); |
1794 } | 1794 } |
1795 | 1795 |
1796 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); | 1796 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); |
1797 | 1797 |
1798 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), | 1798 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), |
1799 new GlobalDate(dateMs)); | 1799 new GlobalDate(dateMs)); |
1800 } | 1800 } |
1801 | 1801 |
1802 function formatDateToParts(formatter, dateValue) { | |
Dan Ehrenberg
2016/08/29 21:05:06
Nit: The general V8 convention is to use CamelCase
| |
1803 var dateMs; | |
1804 if (IS_UNDEFINED(dateValue)) { | |
1805 dateMs = %DateCurrentTime(); | |
1806 } else { | |
1807 dateMs = TO_NUMBER(dateValue); | |
1808 } | |
1809 | |
1810 if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); | |
1811 | |
1812 return %InternalDateFormatToParts( | |
1813 %GetImplFromInitializedIntlObject(formatter), new GlobalDate(dateMs)); | |
1814 } | |
1815 | |
1802 | 1816 |
1803 /** | 1817 /** |
1804 * Returns a Date object representing the result of calling ToString(value) | 1818 * Returns a Date object representing the result of calling ToString(value) |
1805 * according to the effective locale and the formatting options of this | 1819 * according to the effective locale and the formatting options of this |
1806 * DateTimeFormat. | 1820 * DateTimeFormat. |
1807 * Returns undefined if date string cannot be parsed. | 1821 * Returns undefined if date string cannot be parsed. |
1808 */ | 1822 */ |
1809 function IntlParseDate(formatter, value) { | 1823 function IntlParseDate(formatter, value) { |
1810 return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter), | 1824 return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter), |
1811 TO_STRING(value)); | 1825 TO_STRING(value)); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2288 | 2302 |
2289 var locales = arguments[0]; | 2303 var locales = arguments[0]; |
2290 var options = arguments[1]; | 2304 var options = arguments[1]; |
2291 return toLocaleDateTime( | 2305 return toLocaleDateTime( |
2292 this, locales, options, 'time', 'time', 'dateformattime'); | 2306 this, locales, options, 'time', 'time', 'dateformattime'); |
2293 } | 2307 } |
2294 ); | 2308 ); |
2295 | 2309 |
2296 utils.Export(function(to) { | 2310 utils.Export(function(to) { |
2297 to.AddBoundMethod = AddBoundMethod; | 2311 to.AddBoundMethod = AddBoundMethod; |
2312 to.formatDateToParts = formatDateToParts; | |
2298 to.IntlParseDate = IntlParseDate; | 2313 to.IntlParseDate = IntlParseDate; |
2299 to.IntlParseNumber = IntlParseNumber; | 2314 to.IntlParseNumber = IntlParseNumber; |
2300 }); | 2315 }); |
2301 | 2316 |
2302 }) | 2317 }) |
OLD | NEW |