Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed May 5, 2021
1 parent 3e6b0d5 commit 7a276ab
Show file tree
Hide file tree
Showing 30 changed files with 60 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h3 id="parameters">Parameters</h3>
<dl>
<dt><code><var>duration</var></code></dt>
<dd>
<p>An object with properties denoting a duration, such as <code>{ months: 5 }</code>, or a string value such as <code>PT5M</code>, or a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object. If <code><var>duration</var></code> is not such a string nor a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object, then it will be converted to one as if it were passed to <code>{{jsxref('Temporal/Duration/from','Temporal.Duration.from()')}}</code>.</p>
<p>An object with properties denoting a duration, such as <code>{ months: 5 }</code>, or a string value such as <code>P5M</code>, or a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object. If <code><var>duration</var></code> is not such a string nor a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object, then it will be converted to one as if it were passed to <code>{{jsxref('Temporal/Duration/from','Temporal.Duration.from()')}}</code>.</p>
</dd>
<dt><code><var>options</var></code> {{optional_inline}}</dt>
<dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3 id="parameters">Parameters</h3>
<h2 id="return-value">Return value</h2>

<p>A new <code>{{jsxref('Temporal/PlainYearMonth','Temporal.PlainYearMonth')}}</code> object representing the year and month indicated by the original <code>oldMonth</code> minus <code><var>duration</var></code>. If the result is earlier or later than the range that <code>{{jsxref('Temporal/PlainYearMonth','Temporal.PlainYearMonth')}}</code> can represent (just over half a million years centered on the Unix epoch), a <code>RangeError</code> will be thrown instead.
<</p>
</p>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h3 id="parameters">Parameters</h3>
<dt><code><var>duration</var></code></dt>
<dd>
<p>An object with properties denoting a duration, such as <code>{ days: 5, hours: 5, minutes: 30 }</code>, or a string value such as <code>P5DT5H30M</code>, or a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object. If <code><var>duration</var></code> is not such a string nor a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object, then it will be converted to a string as if it were passed to <code>{{jsxref('Temporal/Duration/from','Temporal.Duration.from()')}}</code>.</p>
<p>Some additions may be ambiguous, because months have different lengths. For example, adding <code>{ month: 1 }</code> to August 31 would result in September 31, which doesn’t exist. In such cases, the <code>overflow</code> option (see below) governs the result.</p>
<p>Some additions may be ambiguous, because months have different lengths. For example, adding <code>{ months: 1 }</code> to August 31 would result in September 31, which doesn’t exist. In such cases, the <code>overflow</code> option (see below) governs the result.</p>
</dd>
<dt><code><var>options</var></code> {{optional_inline}}</dt>
<dd>
Expand All @@ -59,9 +59,6 @@ <h3 id="parameters">Parameters</h3>
<dt><code>'reject'</code></dt>
<dd>Out-of-range values will cause the function to throw a <code>RangeError</code>.</dd>
</dl>
<div class="note">
<strong>Note:</strong> The <code>overflow</code> option has no effect in the default ISO calendar, because a year is always 12 months and therefore not ambiguous. However, <code>overflow</code> may have an effect in calendars where years can be different numbers of months.</p>
</div>
</dd>
</dl>
</dd>
Expand All @@ -70,7 +67,7 @@ <h3 id="parameters">Parameters</h3>

<h2 id="return-value">Return value</h2>

<p>A new <code>{{jsxref('Temporal/ZonedDateTime','Temporal.ZonedDateTime')}}</code> object representing the calendar date indicated by <code>ZonedDateTime</code> plus <code><var>duration</var></code> If the result is earlier or later than the range of dates that <code>Temporal.ZonedDateTime</code> can represent (approximately half a million years centered on the Unix epoch), this method will throw a <code>RangeError</code> regardless of value of the <code>overflow</code> option.
<p>A new <code>{{jsxref('Temporal/ZonedDateTime','Temporal.ZonedDateTime')}}</code> object representing the calendar date indicated by <code>oldDateTime</code> plus <code><var>duration</var></code> If the result is earlier or later than the range of dates that <code>Temporal.ZonedDateTime</code> can represent (approximately half a million years centered on the Unix epoch), this method will throw a <code>RangeError</code> regardless of value of the <code>overflow</code> option.
</p>

<h2 id="examples">Examples</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2 id="syntax">Syntax</h2>
<h2 id="value">Value</h2>

<p>A <code>{{jsxref('Temporal/Calendar','Temporal.Calendar')}}</code> object representing the calendar system used to interpret the
<code>{{jsxref('Temporal/ZonedDateTime/year','year')}}</code>, <code>{{jsxref('Temporal/ZonedDateTime/month','month')}}</code>,
<code>{{jsxref('Temporal/ZonedDateTime/year','year')}}</code>, <code>{{jsxref('Temporal/ZonedDateTime/month','month')}}</code>, <code>{{jsxref('Temporal/ZonedDateTime/monthCode','monthCode')}}</code>,
<code>{{jsxref('Temporal/ZonedDateTime/day','day')}}</code>,
<code>{{jsxref('Temporal/ZonedDateTime/hour','hour')}}</code>,
<code>{{jsxref('Temporal/ZonedDateTime/minute','minute')}}</code>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@ <h2 id="return-value">Return value</h2>

<ul>
<li><code>−1</code> if <code><var>dateTimeOne</var></code> comes before <code><var>dateTimeTwo</var></code>;
<li><code>0</code> if all fields of <code><var>dateTimeOne</var></code> and <code><var>dateTimeTwo</var></code> are equal, including the calendar ID and the time zone ID;
<li><code>0</code> if <code><var>dateTimeOne</var></code> and <code><var>dateTimeTwo</var></code> represent the same exact time;
<li><code>1</code> if <code><var>dateTimeOne</var></code> comes after <code><var>dateTimeTwo</var></code>.
</ul>

<p>The comparison uses exact time, not clock time, because sorting is almost always based on when events happened in the real world. During the hour before and after DST (Daylight Saving Time) transitions, sorting of clock time may not match the order the events actually occurred.</p>

<div class="warning">
<p>Note that this function will not return <code>0</code> if the two objects have different <code>calendar</code> or <code>timeZone</code> properties, even if the exact timestamps are equal.</p>
</div>

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

<pre class="brush: js">
Expand All @@ -65,23 +61,3 @@ <h2 id="examples">Examples</h2>
// => -1
// (because `Temporal.Instant` and `Temporal.ZonedDateTime` both compare real-world exact times)
</pre>

<p>In cases where the exact timestamps are equal, but the calendar or time zone portions are different, then the calendar <code>id</code>s will be compared lexicographically, in order to ensure a deterministic sort order. If those are the same, then the time zone <code>id</code>s will be compared lexicographically.</p>

<pre class="brush: js">
arr = [
Temporal.ZonedDateTime.from('2020-02-01T12:30-05:00[America/Toronto]'),
Temporal.ZonedDateTime.from('2020-02-01T12:30-05:00[America/New_York]'),
Temporal.ZonedDateTime.from('2020-02-01T12:30+01:00[Europe/Brussels]'),
Temporal.ZonedDateTime.from('2020-02-01T12:30+00:00[Europe/London]')
];
sorted = arr.sort(Temporal.ZonedDateTime.compare);
JSON.stringify(sorted, undefined, 2);
// =>
// '[
// "2020-02-01T12:30+01:00[Europe/Brussels]",
// "2020-02-01T12:30+00:00[Europe/London]",
// "2020-02-01T12:30-05:00[America/New_York]",
// "2020-02-01T12:30-05:00[America/Toronto]"
// ]'
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
new Temporal.ZonedDateTime(<var>epochNanoseconds</var>, <var>calendar</var>)
new Temporal.ZonedDateTime(<var>epochNanoseconds</var>, <var>timeZone</var>, <var>calendar</var>)
</pre>

<h3 id="parameters">Parameters</h3>
Expand All @@ -25,6 +25,10 @@ <h3 id="parameters">Parameters</h3>
<dd>
<p>A {{jsxref('BigInt')}} number of nanoseconds.</p>
</dd>
<dt><code><var>timeZone</var></code></dt>
<dd>
<p>The time zone, either a <code>{{jsxref('Temporal/TimeZone','Temporal.TimeZone')}}</code> object, or a value that can be converted to one with <code>{{jsxref('Temporal/TimeZone/from','Temporal.TimeZone.from()')}}</code>.
</dd>
<dt><code><var>calendar</var></code> {{ optional_inline }}</dt>
<dd>
<p>A calendar used to interpret the value of <var>epochNanoseconds</var>, in order to reckon the date and time by that calendar system.</p>
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
@@ -1,6 +1,7 @@
---
title: Temporal.ZonedDateTime.epochMicroseconds
slug: Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/epochMicroseconds
slug: >-
Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/epochMicroseconds
tags:
- Class
- Date
Expand All @@ -21,7 +22,7 @@ <h2 id="syntax">Syntax</h2>

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

<p>A {{jsxref('BigInt')}} which is always an integer.</p>
<p>A {{jsxref('BigInt')}}.</p>


<h2 id="examples">Examples</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Temporal.ZonedDateTime.epochNanoseconds
slug: Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/epochNanoseconds
slug: >-
Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/epochNanoseconds
tags:
- Class
- Date
Expand All @@ -9,7 +10,7 @@
---
{{JSRef}}

<p class="summary"><span class="seoSummary">The <strong><code>epochNanoseconds</code></strong> read-only property returns the number of full microseconds between the <code>{{jsxref('Temporal.zonedDateTime','Temporal.zonedDateTime')}}</code> object and 00:00 UTC on 1970-01-01, otherwise known as the UNIX Epoch. Any fractional remainders are truncated towards zero.</p>
<p class="summary"><span class="seoSummary">The <strong><code>epochNanoseconds</code></strong> read-only property returns the number of full nanoseconds between the <code>{{jsxref('Temporal.zonedDateTime','Temporal.zonedDateTime')}}</code> object and 00:00 UTC on 1970-01-01, otherwise known as the UNIX Epoch.</p>


<h2 id="syntax">Syntax</h2>
Expand All @@ -21,7 +22,7 @@ <h2 id="syntax">Syntax</h2>

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

<p>A {{jsxref('BigInt')}} which is always an integer.</p>
<p>A {{jsxref('BigInt')}}.</p>


<h2 id="examples">Examples</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
title: Temporal.ZonedDateTime.from()
slug: Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/from
tags:
– Class
– JavaScript
– date
tags: – Class – JavaScript – date
---
{{JSRef}}

Expand All @@ -15,7 +12,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
var theDate = Temporal.ZonedDateTime.from(<var>dateTime</var>, <var>options</var>);
var theDatetime = Temporal.ZonedDateTime.from(<var>dateTime</var>, <var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down Expand Up @@ -85,7 +82,7 @@ <h3 id="parameters">Parameters</h3>
<li><code>'use'</code> – Evaluate date/time values using the time zone offset if it’s provided in the input. This will keep the exact time unchanged even if local time will be different than what was originally stored.</li>
<li><code>'ignore'</code> – Never use the time zone offset provided in the input. Instead, calculate the offset from the time zone. This will keep local time unchanged but may result in a different exact time than was originally stored.</li>
<li><code>'prefer'</code> – Evaluate date/time values using the offset if it’s valid for this time zone. If the offset is invalid, then calculate the offset from the time zone. This option is rarely used when calling <code>from()</code>. See the documentation of <code>{{jsxref('Temporal.ZonedDateTime/with','with()')}}</code> for more details about why this option is used.</li>
<li><code>'reject'</code> <strong>(default)</strong> – Throw a `RangeError` if the offset is not valid for the provided date and time in the provided time zone.</li>
<li><code>'reject'</code> <strong>(default)</strong> – Throw a <code>RangeError</code> if the offset is not valid for the provided date and time in the provided time zone.</li>
</ul>

</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
---
{{JSRef}}

<p class="summary"><span class="seoSummary"><code>Temporal.ZonedDateTime</code> is a time-zone-aware, calendar-aware date-and-time type that represents a real event that has happened (or will happen) at a particular instant from the perspective of a particular region on Earth.</span> As the broadest Temporal type, <code>Temporal.ZonedDateTime</code> can be considered a combination of <code>{{jsxref('Temporal.TimeZone','Temporal.TimeZone')}}</code>, <code>{{jsxref('Temporal.Instant','Temporal.Instant')}}</code>, and <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code> (which includes <code>{{jsxref('Temporal.Calendar','Temporal.Calendar')}}</code>).</p>
<p class="summary"><span class="seoSummary"><code>Temporal.ZonedDateTime</code> is a time-zone-aware, calendar-aware date-and-time type that represents a real event that has happened (or will happen) at a particular instant from the perspective of a particular region on Earth.</span> As the broadest Temporal type, <code>Temporal.ZonedDateTime</code> can be considered a combination of <code>{{jsxref('Temporal.TimeZone','Temporal.TimeZone')}}</code>, <code>{{jsxref('Temporal.Instant','Temporal.Instant')}}</code>, and <code>{{jsxref('Temporal.PlainDateTime','Temporal.PlainDateTime')}}</code> (which includes <code>{{jsxref('Temporal.Calendar','Temporal.Calendar')}}</code>).</p>
<p>As the only Temporal type that persists a time zone, <code>Temporal.ZonedDateTime</code> is optimized for use cases that require a time zone. This means:</p>

<ul>
Expand All @@ -40,6 +40,8 @@ <h2 id="instance_properties">Instance Properties</h2>
<dd><p>The year in which the date and time occurs.</p></dd>
<dt><code>{{jsxref('Temporal/ZonedDateTime/month','month')}}</code> {{readonlyinline}}</dt>
<dd><p>The number of the month in which the date and time occurs.</p></dd>
<dt><code>{{jsxref('Temporal/ZonedDateTime/monthCode','monthCode')}}</code> {{readonlyinline}}</dt>
<dd><p>TK</p></dd>
<dt><code>{{jsxref('Temporal/ZonedDateTime/day','day')}}</code> {{readonlyinline}}</dt>
<dd><p>The day of the month on which the date and time occurs.</p></dd>
<dt><code>{{jsxref('Temporal/ZonedDateTime/hour','hour')}}</code> {{readonlyinline}}</dt>
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>A boolean value of <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">
var newTime = ZonedDateTime.round(<var>options</var>);
var newDateTime = oldDateTime.round(<var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
---
{{JSRef}}

<p class="summary"><span class="seoSummary">The <strong><code>since()</code></strong> method computes the elapsed time between the date and time represented by <code>ZonedDateTime</code> and another date and time in the past, optionally rounds it, and returns it as a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object.</span> If the second date and time is later than the first, then the resulting duration will be negative. This method is similar to <code>{{jsxref('Temporal.ZonedDateTime/until','Temporal.ZonedDateTime.until()')}}</code>, but reversed.</p>
<p class="summary"><span class="seoSummary">The <strong><code>since()</code></strong> method computes the elapsed time between the date and time represented by <code>zonedDateTime</code> and another date and time in the past, optionally rounds it, and returns it as a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object.</span> If the second date and time is later than the first, then the resulting duration will be negative. This method is similar to <code>{{jsxref('Temporal.ZonedDateTime/until','Temporal.ZonedDateTime.until()')}}</code>, but reversed.</p>

<p>The duration returned is a “hybrid” duration. This means that the duration's date portion represents full calendar days like <code>{{jsxref('Temporal.PlainDateTime/until','Temporal.PlainDateTime.until()')}}</code> would return, while its time portion represents real-world elapsed time like <code>{{jsxref('Temporal.Instant/until','Temporal.Instant.until()')}}</code> would return. This "hybrid duration" approach automatically adjusts for DST and matches widely-adopted industry standards like RFC 5545 (iCalendar). It also matches the behavior of popular JavaScript libraries like moment.js and date-fns.</p>

Expand All @@ -32,7 +32,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
var timeBetween = dateTime.since(<var>otherZonedDateTime</var> [, <var>options</var>]);
var timeBetween = zonedDateTime.since(<var>otherZonedDateTime</var>, <var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
---
{{JSRef}}

<p class="summary"><span class="seoSummary">The <strong><code>startOfDay</code></strong> read-only property returns a new <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code> instance representing the earliest valid local clock time during the given calendar day and time zone.</span> The local time of the result is almost always <code>00:00</code>, but in rare cases it could be a later time e.g. if DST (Daylight Saving Time) starts at midnight in a time zone. Also note that some calendar systems (e.g., <code>ethiopic</code>) may not start days at <code>00:00</code>.</p>
<p class="summary"><span class="seoSummary">The <strong><code>startOfDay</code></strong> read-only property returns a new <code>{{jsxref('Temporal.ZonedDateTime','Temporal.ZonedDateTime')}}</code> instance representing the earliest valid local clock time during the given calendar day and time zone.</span> The local time of the result is almost always <code>00:00</code>, but in rare cases it could be a later time e.g. if DST (Daylight Saving Time) starts at midnight in a time zone.</p>


<h2 id="syntax">Syntax</h2>
Expand Down
Loading

0 comments on commit 7a276ab

Please sign in to comment.