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

Unified 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: rebased 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 side-by-side diff with in-line comments
Download patch
Index: src/js/i18n.js
diff --git a/src/js/i18n.js b/src/js/i18n.js
index 6046a6f2f9438a68c9c9c8c3f9762aae04bb826d..65415fb854929b6d35f4cc85db1f21d2f2de909c 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -1797,6 +1797,29 @@ function formatDate(formatter, dateValue) {
new GlobalDate(dateMs));
}
+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.
+ if (!IS_UNDEFINED(new.target)) {
+ throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
+ }
+ CHECK_OBJECT_COERCIBLE(this, "Intl.DateTimeFormat.prototype.formatToParts");
+ if (!IS_OBJECT(this)) {
+ throw %make_type_error(kCalledOnNonObject, this);
+ }
+ 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(this), new GlobalDate(dateMs));
+}
+
+%FunctionSetLength(formatDateToParts, 0);
+
/**
* Returns a Date object representing the result of calling ToString(value)
@@ -2291,8 +2314,11 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
}
);
+%FunctionRemovePrototype(formatDateToParts);
+
utils.Export(function(to) {
to.AddBoundMethod = AddBoundMethod;
+ to.formatDateToParts = formatDateToParts;
to.IntlParseDate = IntlParseDate;
to.IntlParseNumber = IntlParseNumber;
});

Powered by Google App Engine
This is Rietveld 408576698