Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: src/js/i18n.js

Issue 2273953003: Add support for DateTimeFormat.formatToParts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update test262.status Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/datetime-format-to-parts.js ('k') | src/js/prologue.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
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
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 })
OLDNEW
« no previous file with comments | « src/js/datetime-format-to-parts.js ('k') | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698