Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed May 13, 2021
1 parent afb0554 commit f09c494
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<p class="summary"><span class="seoSummary">The <strong><code>toLocaleString()</code></strong> method returns a human-readable, language-sensitive representation of the <code>{{jsxref('Temporal.Duration','Temporal.Duration')}}</code> value.</span> This method overrides {{jsxref('Object/toLocaleString','Object.prototype.toLocaleString()')}}.</p>

<div class="warning">
<p>This method requires that your JavaScript environment supports <code>Intl.DurationFormat</code>. If <code>{{jsxref('Intl.DurationFormat')}}</code> is not available, then the output of this method is the same as that of <code>{{jsxref('Temporal.Duration./toString','Temporal.Duration.toString()')}}</code>, and the <code>locales</code> and <code>options</code> arguments are ignored.</p>
<p>This method requires that your JavaScript environment supports <code>Intl.DurationFormat</code>. If <code>{{jsxref('Intl.DurationFormat')}}</code> is not available, then the output of this method is the same as that of <code>{{jsxref('Temporal/Duration/toString','Temporal.Duration.toString()')}}</code>, and the <code>locales</code> and <code>options</code> arguments are ignored.</p>
</div>

<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
date.toLocaleString(<var>locales</var>, <var>options</var>);
duration.toLocaleString(<var>locales</var>, <var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand All @@ -45,64 +45,24 @@ <h3 id="parameters">Parameters</h3>
"<code>limb</code>", "<code>mlym</code>", "<code>mong</code>",
"<code>mymr</code>", "<code>orya</code>", "<code>tamldec</code>",
"<code>telu</code>", "<code>thai</code>", "<code>tibt</code>".</dd>
<dt><code>ca</code></dt>
<dd>Calendar. Possible values include: "<code>buddhist</code>",
"<code>chinese</code>", "<code>coptic</code>", "<code>ethiopia</code>",
"<code>ethiopic</code>", "<code>gregory</code>", "<code>hebrew</code>",
"<code>indian</code>", "<code>islamic</code>", "<code>iso8601</code>",
"<code>japanese</code>", "<code>persian</code>", "<code>roc</code>".</dd>
<dt><code>hc</code></dt>
<dd>Hour cycle. Possible values include: "<code>h11</code>",
"<code>h12</code>", "<code>h23</code>", "<code>h24</code>".</dd>
</dl>
</dd>
<dt><code><var>options</var></code> {{optional_inline}}</dt>
<dd>
<p>An object with some or all of the following properties:</p>

<dl>
<dt><code>dateStyle</code></dt>
<dd>The date formatting style to use when calling <code>format()</code>.
<dt><code>style</code></dt>
<dd>The formatting style to use when calling <code>format()</code>.
Possible values include:
<ul>
<li>"<code>full</code>"</li>
<li>"<code>long</code>"</li>
<li>"<code>medium</code>"</li>
<li>"<code>short</code>"</li>
<li>"<code>narrow</code>"</li>
<li>"<code>digital</code>"</li>
</ul>

<div class="notecard note">
<p><code>dateStyle</code> can be used with <code>timeStyle</code>, but
not with other options (e.g. <code>weekday</code>,
<code>hour</code>, <code>month</code>, etc.).</p>
</div>
</dd>
<dt><code>timeStyle</code></dt>
<dd>The time formatting style to use when calling <code>format()</code>.
Possible values include:
<ul>
<li>"<code>full</code>"</li>
<li>"<code>long</code>"</li>
<li>"<code>medium</code>"</li>
<li>"<code>short</code>"</li>
</ul>
</dd>
<dd>
<div class="notecard note">
<p><code>timeStyle</code> can be used with <code>dateStyle</code>, but
not with other options (e.g. <code>weekday</code>,
<code>hour</code>, <code>month</code>, etc.).</p>
</div>
</dd>
<dt><code>calendar</code></dt>
<dd>Calendar. Possible values include: "<code>buddhist</code>",
"<code>chinese</code>", " <code>coptic</code>", "<code>ethiopia</code>",
"<code>ethiopic</code>", "<code>gregory</code>", " <code>hebrew</code>",
"<code>indian</code>", "<code>islamic</code>", "<code>iso8601</code>", "
<code>japanese</code>", "<code>persian</code>", "<code>roc</code>".</dd>
<dt><code>dayPeriod</code></dt>
<dd>The way day periods should be expressed. Possible values include:
"<code>narrow</code>", "<code>short</code>", " <code>long</code>".</dd>

<dt><code>numberingSystem</code></dt>
<dd>Numbering System. Possible values include: "<code>arab</code>",
"<code>arabext</code>", " <code>bali</code>", "<code>beng</code>",
Expand All @@ -118,139 +78,16 @@ <h3 id="parameters">Parameters</h3>
"<code>best fit</code>". For information about this option, see the
{{jsxref("Global_Objects/Intl", "Intl", "#Locale_negotiation", 1)}} page.
</dd>
<dt><code>timeZone</code></dt>
<dd>The time zone to use. The only value implementations must recognize is
"<code>UTC</code>"; the default is the runtime's default time zone.
Implementations may also recognize the time zone names of the <a
href="https://www.iana.org/time-zones">IANA time zone database</a>,
such as "<code>Asia/Shanghai</code>", "<code>Asia/Kolkata</code>",
"<code>America/New_York</code>".
</dd>
<dt><code>hour12</code></dt>
<dd>Whether to use 12-hour time (as opposed to 24-hour time). Possible values
are <code>true</code> and <code>false</code>; the default is locale
dependent. This option overrides the <code>hc</code> language tag and/or
the <code>hourCycle</code> option in case both are present.</dd>
<dt><code>hourCycle</code></dt>
<dd>The hour cycle to use. Possible values are "<code>h11</code>",
"<code>h12</code>", "<code>h23</code>", or "<code>h24</code>". This option
overrides the <code>hc</code> language tag, if both are present, and the
<code>hour12</code> option takes precedence in case both options have been
specified.</dd>
<dt><code>formatMatcher</code></dt>
<dd>The format matching algorithm to use. Possible values are
"<code>basic</code>" and "<code>best fit</code>"; the default is
"<code>best fit</code>". See the following paragraphs for information
about the use of this property.</dd>
</dl>

<p>The following properties describe the date-time components to use in formatted
output, and their desired representations. Implementations are required to
support at least the following subsets:</p>

<ul>
<li><code>weekday</code>, <code>year</code>, <code>month</code>,
<code>day</code>, <code>hour</code>, <code>minute</code>,
<code>second</code></li>
<li><code>weekday</code>, <code>year</code>, <code>month</code>,
<code>day</code></li>
<li><code>year</code>, <code>month</code>, <code>day</code></li>
<li><code>year</code>, <code>month</code></li>
<li><code>month</code>, <code>day</code></li>
<li><code>hour</code>, <code>minute</code>, <code>second</code></li>
<li><code>hour</code>, <code>minute</code></li>
</ul>

<p>Implementations may support other subsets, and requests will be negotiated
against all available subset-representation combinations to find the best
match. Two algorithms are available for this negotiation and selected by the
<code>formatMatcher</code> property: A <a
href="http://www.ecma-international.org/ecma-402/1.0/#BasicFormatMatcher">fully
specified "<code>basic</code>" algorithm</a> and an
implementation-dependent "<code>best fit</code>" algorithm.</p>

<dl>
<dt><code>weekday</code></dt>
<dd>The representation of the weekday. Possible values are:
<ul>
<li>"<code>long</code>" (e.g., <code>Thursday</code>)</li>
<li>"<code>short</code>" (e.g., <code>Thu</code>)</li>
<li>"<code>narrow</code>" (e.g., <code>T</code>). Two weekdays may
have the same narrow style for some locales (e.g.
<code>Tuesday</code>'s narrow style is also <code>T</code>).</li>
</ul>
<dt><code>smallestUnit</code></dt>
<dd>TK - this is still being determined in the Intl.DurationFormat proposal
</dd>
<dt><code>era</code></dt>
<dd>The representation of the era. Possible values are:
<ul>
<li>"<code>long</code>" (e.g., <code>Anno Domini</code>)</li>
<li>"<code>short</code>" (e.g., <code>AD</code>)</li>
<li>"<code>narrow</code>" (e.g., <code>A</code>)</li>
</ul>
<dt><code>largestUnit</code></dt>
<dd>TK - this is still being determined in the Intl.DurationFormat proposal
</dd>
<dt><code>year</code></dt>
<dd>The representation of the year. Possible values are:
<ul>
<li>"<code>numeric</code>" (e.g., <code>2012</code>)</li>
<li>"<code>2-digit</code>" (e.g., <code>12</code>)</li>
</ul>
</dd>
<dt><code>month</code></dt>
<dd>The representation of the month. Possible values are:
<ul>
<li>"<code>numeric</code>" (e.g., <code>2</code>)</li>
<li>"<code>2-digit</code>" (e.g., <code>02</code>)</li>
<li>"<code>long</code>" (e.g., <code>March</code>)</li>
<li>"<code>short</code>" (e.g., <code>Mar</code>)</li>
<li>"<code>narrow</code>" (e.g., <code>M</code>). Two months may have
the same narrow style for some locales (e.g. <code>May</code>'s
narrow style is also <code>M</code>).</li>
</ul>
</dd>
<dt><code>day</code></dt>
<dd>The representation of the day. Possible values are:
<ul>
<li>"<code>numeric</code>" (e.g., <code>1</code>)</li>
<li>"<code>2-digit</code>" (e.g., <code>01</code>)</li>
</ul>
</dd>
<dt><code>hour</code></dt>
<dd>The representation of the hour. Possible values are
"<code>numeric</code>", "<code>2-digit</code>".</dd>
<dt><code>minute</code></dt>
<dd>The representation of the minute. Possible values are
"<code>numeric</code>", "<code>2-digit</code>".</dd>
<dt><code>second</code></dt>
<dd>The representation of the second. Possible values are
"<code>numeric</code>", "<code>2-digit</code>".</dd>
<dt><code>fractionalSecondDigits</code></dt>
<dd>
The number of digits used to represent fractions of a second (any
additional digits are truncated). Possible values are:

<ul>
<li><code>0</code> (Fractional part dropped.)</li>
<li><code>1</code> (Fractional part represented as 1 digit. For
example, 736 is formatted as <code>7</code>.)</li>
<li><code>2</code> (Fractional part represented as 2 digits. For
example, 736 is formatted as <code>73</code>.)</li>
<li><code>3</code> (Fractional part represented as 3 digits. For
example, 736 is formatted as <code>736</code>.)</li>
</ul>
</dd>
<dt><code>timeZoneName</code></dt>
<dd>The representation of the time zone name. Possible values are:
<ul>
<li>"<code>long</code>" (e.g., <code>British Summer Time</code>)</li>
<li>"<code>short</code>" (e.g., <code>GMT+1</code>)</li>
</ul>
<dt><code>hideZeroValued</code></dt>
<dd>TK - this is still being determined in the Intl.DurationFormat proposal
</dd>
</dl>

<p class="noinclude">The default value for each date-time component property is
{{jsxref("undefined")}}, but if all component properties are
{{jsxref("undefined")}}, then <code>year</code>, <code>month</code>, and
<code>day</code> are assumed to be "<code>numeric</code>".</p>
</dd>
</dl>

Expand All @@ -264,5 +101,5 @@ <h2 id="examples">Examples</h2>
d = Temporal.Duration.from('P1DT6H30M');
d.toLocaleString(); // example output: '1 day 6 hours 30 minutes'
d.toLocaleString('de-DE'); // example output: '1 Tag 6 Stunden 30 Minuten'
d.toLocaleString('en-US', { day: 'numeric', hour: 'numeric' }); // example output: '1 day 6 hours'
d.toLocaleString('en-US', { smallestUnit: 'hour' }); // example output: '1 day 6 hours'
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
time.toString(<var>options</var>);
duration.toString(<var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down Expand Up @@ -66,11 +66,11 @@ <h2 id="return-value">Return Value</h2>
<h2 id="examples">Examples</h2>

<pre class="brush: js">
time = Temporal.Duration.from('19:39:09.068346205');
time.toString(); // => '19:39:09.068346205'
time.toString({ smallestUnit: 'minute' }); // => '19:39'
time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09'
time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683'
time.toString({ fractionalSecondDigits: 5, roundingMode: 'halfExpand' });
duration = Temporal.Duration.from('19:39:09.068346205');
duration.toString(); // => '19:39:09.068346205'
duration.toString({ smallestUnit: 'minute' }); // => '19:39'
duration.toString({ fractionalSecondDigits: 0 }); // => '19:39:09'
duration.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683'
duration.toString({ fractionalSecondDigits: 5, roundingMode: 'halfExpand' });
// => '19:39:09.06835'
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 id="syntax">Syntax</h2>

<h2 id="value">Value</h2>

<p>An integer representing the weekday number on which the date falls. In the ISO 8601 calendar, this is always <code>7</code>, but in other calendar systems the value may vary from week to week.</p>
<p>An integer representing the weekday number on which the date falls.

<h2 id="examples">Examples</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 id="syntax">Syntax</h2>

<h2 id="value">Value</h2>

<p>An integer representing the number of days in the month. This is <code>28</code>, <code>29</code>, <code>30</code>, or <code>31</code>, depending on the month and whether the year is a leap year.</p>
<p>An integer representing the number of days in the month. In the ISO 8601 calendar, this is <code>28</code>, <code>29</code>, <code>30</code>, or <code>31</code>, depending on the month and whether the year is a leap year.</p>

<h2 id="examples">Examples</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 id="syntax">Syntax</h2>

<h2 id="value">Value</h2>

<p>An boolean set to <code>true</code> if the date occurs in a leap year, or <code>false</code> if not.</p>
<p>The value <code>true</code> if the date occurs in a leap year, or <code>false</code> if not.</p>

<h2 id="examples">Examples</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
Date.toJSON();
date.toJSON();
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h3 id="parameters">Parameters</h3>
<dd><p>A time zone represented by a <code>{{jsxref('Temporal.TimeZone','Temporal.TimeZone')}}</code> object, an object implementing the Temporal time zone protocol, or a value that can be converted to one as if it were passed to <code>{{jsxref('Temporal.TimeZone/from','Temporal.TimeZone.from()')}}</code>.</p></dd>
<dt><code>plainTime</code> {{ optional_inline }}</dt>
<dd><p>A time represented by a <code>{{jsxref('Temporal.PlainTime','Temporal.PlainTime')}}</code> object, or a value that can be converted to one as if it were passed to <code>{{jsxref('Temporal.PlainTime/from','Temporal.PlainTime.from()')}}</code>.</p>
<p>If no <code>plainTime</code> is provided, it defaults to the first valid local time in <code>timeZone</code> on the calendar date. Usually this is midnight (<code>00:00</code>), but may be a different time in rare circumstances like <abbr title="Daylight Saving Time">DST</abbr> starting at midnight, or calendars like <code>ethiopic</code> where not every day starts at midnight.</p></dd>
<p>If no <code>plainTime</code> is provided, it defaults to the first valid local time in <code>timeZone</code> on the calendar date. Usually this is midnight (<code>00:00</code>), but may be a different time in rare circumstances like <abbr title="Daylight Saving Time">DST</abbr> starting at midnight.
</dl>
</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
---
{{JSRef}}

<p class="summary"><span class="seoSummary">The <strong><code>withCalendar()</code></strong> method returns a <code>{{jsxref('Temporal.PlainDate','Temporal.PlainDate')}}</code> object of a date projected into a specified calendar.</span> This method is functionally equivalent as <code>date{{jsxref('Temporal.PlainDate/with','.with({ calendar })')}}</code>, but may be more efficient.
</p>
<p class="summary"><span class="seoSummary">The <strong><code>withCalendar()</code></strong> method returns a <code>{{jsxref('Temporal.PlainDate','Temporal.PlainDate')}}</code> object of a date projected into a specified calendar.</span></p>


<h2 id="syntax">Syntax</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 id="syntax">Syntax</h2>

<h2 id="value">Value</h2>

<p>An integer representing the weekday number on which the date falls. In the ISO 8601 calendar, this is always <code>7</code>, but in other calendar systems the value may vary from week to week.</p>
<p>An integer representing the weekday number on which the date falls.</p>

<h2 id="examples">Examples</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 id="syntax">Syntax</h2>

<h2 id="value">Value</h2>

<p>An integer representing the number of days in the month. This is <code>28</code>, <code>29</code>, <code>30</code>, or <code>31</code>, depending on the month and whether the year is a leap year.</p>
<p>An integer representing the number of days in the month. In the ISO 8601 calendar, this is <code>28</code>, <code>29</code>, <code>30</code>, or <code>31</code>, depending on the month and whether the year is a leap year.</p>

<h2 id="examples">Examples</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 id="syntax">Syntax</h2>

<h2 id="value">Value</h2>

<p>An boolean set to <code>true</code> if the date occurs in a leap year, or <code>false</code> if not.</p>
<p>The value <code>true</code> if the date occurs in a leap year, or <code>false</code> if not.</p>

<h2 id="examples">Examples</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
Date.toJSON();
dateTime.toJSON();
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
date.toString(<var>options</var>);
dateTime.toString(<var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3 id="parameters">Parameters</h3>
When interoperating with existing code or services, <code>'compatible'</code> matches the behavior of legacy <code>{{jsxref('Date')}}</code> as well as libraries like moment.js, Luxon, and date-fns. This mode also matches the behavior of cross-platform standards like RFC 5545 (iCalendar).
</p>
<p>
During “skipped” clock time like the hour after <abbr title="Daylight Saving Time">DST</abbr> starts in the Spring, this method interprets invalid times using the pre-transition time zone offset if <code>'compatible'</code> or <code>'later'</code> is used, or if the post-transition time zone offset if <code>'earlier'</code> is used. This behavior avoids exceptions when converting non-existent <code>{{jsxref('Temporal.PlainDateTime','Temporal.PlainDateTime')}}</code> values to <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code>, but it also means that values during these periods will result in a different <code>{{jsxref('Temporal.PlainDateTime','Temporal.PlainDateTime')}}</code> than doing "“round-trip” conversions to <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code> and back again.
During “skipped” clock time like the hour after <abbr title="Daylight Saving Time">DST</abbr> starts in the Spring, this method interprets invalid times using the pre-transition time zone offset if <code>'compatible'</code> or <code>'later'</code> is used, or if the post-transition time zone offset if <code>'earlier'</code> is used. This behavior avoids exceptions when converting non-existent <code>{{jsxref('Temporal.PlainDateTime','Temporal.PlainDateTime')}}</code> values to <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code>, but it also means that values during these periods will result in a different <code>{{jsxref('Temporal.PlainDateTime','Temporal.PlainDateTime')}}</code> than doing “round-trip” conversions to <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code> and back again.
</p>
</dd>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
<var>date</var>.valueOf();
<var>dateTime</var>.valueOf();
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
Loading

0 comments on commit f09c494

Please sign in to comment.