Chromium Code Reviews| Index: src/js/i18n.js |
| diff --git a/src/js/i18n.js b/src/js/i18n.js |
| index ffef1e8954c6d82e9d921eca41c3e95c81766a61..1aca01af56c81c929df9e9a8c3c6b35e95299438 100644 |
| --- a/src/js/i18n.js |
| +++ b/src/js/i18n.js |
| @@ -1799,6 +1799,20 @@ function formatDate(formatter, dateValue) { |
| new GlobalDate(dateMs)); |
| } |
| +function formatDateToParts(formatter, dateValue) { |
| + var dateMs; |
| + if (IS_UNDEFINED(dateValue)) { |
| + dateMs = %DateCurrentTime(); |
| + } else { |
| + dateMs = TO_NUMBER(dateValue); |
| + } |
| + |
| + if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange); |
| + |
| + return %InternalDateFormatToParts( |
| + %GetImplFromInitializedIntlObject(formatter), new GlobalDate(dateMs)); |
| +} |
| + |
| /** |
| * Returns a Date object representing the result of calling ToString(value) |
| @@ -1814,6 +1828,8 @@ function IntlParseDate(formatter, value) { |
| // 0 because date is optional argument. |
| AddBoundMethod(Intl.DateTimeFormat, 'format', formatDate, 0, 'dateformat'); |
| +AddBoundMethod(Intl.DateTimeFormat, 'formatToParts', formatDateToParts, 0, |
|
Dan Ehrenberg
2016/08/26 19:07:10
Could you put this feature behind a flag and only
|
| + 'dateformat'); |
| /** |