From d192fb918b0e2aa8869de6dcc59de8464b6e879a Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Fri, 11 Dec 2020 18:59:39 -0500 Subject: dump 2020-12-11 --- .../reference/global_objects/array/sort/index.html | 19 ++-- .../intl/datetimeformat/datetimeformat/index.html | 60 +++++++++++- .../intl/datetimeformat/formatrange/index.html | 26 +++--- .../datetimeformat/supportedlocalesof/index.html | 103 ++++++--------------- .../global_objects/intl/listformat/index.html | 4 + .../intl/numberformat/formattoparts/index.html | 4 +- 6 files changed, 117 insertions(+), 99 deletions(-) (limited to 'files/ja/web/javascript/reference') diff --git a/files/ja/web/javascript/reference/global_objects/array/sort/index.html b/files/ja/web/javascript/reference/global_objects/array/sort/index.html index 6719c55cd4..77437acb42 100644 --- a/files/ja/web/javascript/reference/global_objects/array/sort/index.html +++ b/files/ja/web/javascript/reference/global_objects/array/sort/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/sort ---
{{JSRef}}
-

sort() メソッドは、配列の要素を in place でソートします。既定のソート順は昇順で、要素を文字列に変換してから、UTF-16 コード単位の値の並びとして比較します。

+

sort() メソッドは、配列の要素を in place でソートします。既定のソート順は昇順で、要素を文字列に変換してから、UTF-16 コード単位の値の並びとして比較します。

このソートで消費される CPU時間やメモリースペースは実装に依存するので、ここで言及することは出来ません。

@@ -27,22 +27,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/sort

引数

+
+
firstEl
+
比較対象の一つ目の要素を指定します。
+
secondEl
+
比較対象の二つ目の要素を指定します。
+
+
compareFunction {{optional_inline}}
ソート順を定義する関数を指定します。省略された場合、配列の各要素は文字列に変換され、各文字の Unicode のコードポイント順に従ってソートされます。
-
-
firstEl
-
比較対象の一つ目の要素を指定します。
-
secondEl
-
比較対象の二つ目の要素を指定します。
-
-
-

返値

-

ソートされた結果の配列。ソートは対象配列上で in place に行われることに注意して下さい。コピーされた別の配列が準備されることはありません。

+

ソートされた結果の配列。ソートは対象配列上で in place に行われることに注意して下さい。コピーされた別の配列が準備されることはありません。

解説

diff --git a/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.html b/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.html index 049e69396d..76ae82a7c6 100644 --- a/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.html +++ b/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.html @@ -20,14 +20,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/Date

構文

-
new Intl.DateTimeFormat([locales[, options]])
+
new Intl.DateTimeFormat([locales[, options]])

引数

locales {{optional_inline}}
-

BCP47 言語タグの文字列、または、そのような文字列の配列です。ブラウザーの既定のロケールを使用するには、この引数を省略するか、 undefined を渡すかしてください。 Unicode 拡張に対応しています (例えば "en-US-u-ca-buddhist" など)。 locales 引数の一般的な形式と解釈は、 {{jsxref("Global_Objects/Intl", "Intl", "#Locale_identification_and_negotiation", 1)}} のページをご覧ください。次の Unicode 拡張キーが利用できます。

+

BCP47 言語タグの文字列、または、そのような文字列の配列です。ブラウザーの既定のロケールを使用するには、空の配列を渡してください。。 Unicode 拡張に対応しています (例えば "en-US-u-ca-buddhist" など)。 locales 引数の一般的な形式と解釈は、 {{jsxref("Global_Objects/Intl", "Intl", "#Locale_identification_and_negotiation", 1)}} のページをご覧ください。次の Unicode 拡張キーが利用できます。

nu
@@ -51,6 +51,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/Date
  • "medium"
  • "short"
  • + +
    +

    dateStyletimeStyle と一緒に使用することができますが、他のオプションと一緒に使用することができません (例えば weekday, hour, month, など)。

    +
    timeStyle
    format() が呼び出された際に使用される時刻の書式化スタイルです。利用可能な値は以下のとおりです。 @@ -61,8 +65,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/Date
  • "short"
  • -
    fractionalSecondDigits
    -
    format() を呼び出したときに適用する秒の小数点以下の桁数です。有効な値は 0-3 です。
    +
    +
    +

    timeStyledateStyle と一緒に使用することができますが、他のオプションと一緒に使用することができません (例えば weekday, hour, month, など)。

    +
    +
    calendar
    暦です。有効な値は、 "buddhist", "chinese", " coptic", "ethiopia", "ethiopic", "gregory", " hebrew", "indian", "islamic", "iso8601", " japanese", "persian", "roc" です。
    dayPeriod
    @@ -142,6 +149,20 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/Date
    分の表現です。利用可能な値は "numeric", "2-digit" です。
    second
    秒の表現です。利用可能な値は "numeric", "2-digit" です。
    +
    fractionalSecondDigits
    +
    +
    +

    Firefox 84, Chrome 84, などで追加されました。詳しくは互換性一覧表を参照してください。

    +
    + 秒の小数点以下を表すために使用される数字の桁数 (その先の桁は切り捨てられます)。利用可能な値は次の通りです。 + +
      +
    • 0 (小数点以下は切り捨て)
    • +
    • 1 (小数点以下は1桁で表される。例えば、 736 は 7 と書式化される。)
    • +
    • 2 (小数点以下は2桁で表される。例えば、 736 は 73 と書式化される。)
    • +
    • 3 (小数点以下は2桁で表される。例えば、 736 は 736 と書式化される。)
    • +
    +
    timeZoneName
    タイムゾーン名の表現です。利用可能な値は以下の通りです。
      @@ -155,6 +176,37 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/Date
    +

    + +

    DateTimeFormat の使用

    + +

    ロケールを指定しない基本的な使用方法では、 DateTimeFormat は既定のロケールとオプションを使用します。

    + +
    var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
    +
    +// toLocaleString without arguments depends on the implementation,
    +// the default locale, and the default time zone
    +console.log(new Intl.DateTimeFormat().format(date));
    +// → "12/19/2012" if run with en-US locale (language) and time zone America/Los_Angeles (UTC-0800)
    + +

    timeStyle と dateStyle の使用

    + +
    let o = new Intl.DateTimeFormat("en" , {
    +  timeStyle: "short"
    +});
    +console.log(o.format(Date.now())); // "13:31 AM"
    +
    +let o = new Intl.DateTimeFormat("en" , {
    +  dateStyle: "short"
    +});
    +console.log(o.format(Date.now())); // "07/07/20"
    +
    +let o = new Intl.DateTimeFormat("en" , {
    +  timeStyle: "medium",
    +  dateStyle: "short"
    +});
    +console.log(o.format(Date.now())); // "07/07/20, 13:31:55 AM"
    +

    仕様書

    diff --git a/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.html b/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.html index 39d0d6212e..36091b38c9 100644 --- a/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.html +++ b/files/ja/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.html @@ -10,23 +10,23 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/form ---
    {{JSRef}}
    -

    Intl.DateTimeFormat.prototype.formatRange() は、日付の範囲をもっとも簡明な方法で、 {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} オブジェクトがインスタンス化されたときに提供された localeoptions に基づいて書式化します。

    +

    Intl.DateTimeFormat.prototype.formatRange() は、日付の範囲をもっとも簡明な方法で、 {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} オブジェクトがインスタンス化されたときに提供された localeoptions に基づいて書式化します。

    {{EmbedInteractiveExample("pages/js/intl-datetimeformat-prototype-formatrange.html", "taller")}}
    - +

    構文

    -
    Intl.DateTimeFormat.prototype.formatRange(startDate, endDate)
    +
    Intl.DateTimeFormat.prototype.formatRange(startDate, endDate)

    -

    基本的な formatRange の使用

    +

    基本的な formatRange の使用

    -

    このメソッドは2つの {{jsxref("Date")}} を受け取り、 {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} オブジェクトがインスタンス化されたときに提供された localeoptions に基づいて日付の範囲を書式化します。

    +

    このメソッドは2つの {{jsxref("Date")}} を受け取り、 {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} オブジェクトがインスタンス化されたときに提供された localeoptions に基づいて日付の範囲を書式化します。

    -
    let date1 = new Date(Date.UTC(2007, 0, 10, 10, 0, 0));
    +
    let date1 = new Date(Date.UTC(2007, 0, 10, 10, 0, 0));
     let date2 = new Date(Date.UTC(2007, 0, 10, 11, 0, 0));
     let date3 = new Date(Date.UTC(2007, 0, 20, 10, 0, 0));
     // > 'Wed, 10 Jan 2007 10:00:00 GMT'
    @@ -66,19 +66,23 @@ console.log(fmt2.formatRange(date1, date3));
      
    - - - - - +
    仕様書状態備考
    Intl.DateTimeFormat.prototype.formatRangeStage 3{{SpecName('Intl.DateTimeFormat.formatRange', '#sec-intl.datetimeformat.prototype.formatRange', 'formatRange()')}}
    +

    ブラウザーの互換性

    + +
    + + +

    {{Compat("javascript.builtins.Intl.DateTimeFormat.formatRange")}}

    +
    +

    関連情報