Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed May 3, 2021
1 parent 23817d9 commit 6fc83fc
Show file tree
Hide file tree
Showing 29 changed files with 40 additions and 51 deletions.
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">
var invertedTime = time.abs();
var positiveDuration = duration.abs();
</pre>


Expand All @@ -27,8 +27,8 @@ <h2 id="return-value">Return value</h2>
<h2 id="examples">Examples</h2>

<pre class="brush: js">
d = Temporal.Duration.from('P1Y2M3DT4H5M6.987654321S');
d.sign; // 1
d.abs(); // -P1Y2M3DT4H5M6.987654321S
d.abs().sign; // -1
d = Temporal.Duration.from('-P1Y2M3DT4H5M6.987654321S');
d.sign; // -1
d.abs(); // P1Y2M3DT4H5M6.987654321S
d.abs().sign; // 1
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3 id="parameters">Parameters</h3>
</dl>

<div class="note">
If any of the <code>years</code>, <code>months</code>, or <code>weeks</code> properties of either of the durations are nonzero, then the <code>relativeTo</code> option (and thus the <var>options</var> object) is <strong>required</strong>. This is because comparing durations with years, months, or weeks requires a point on the calendar to figure out how long they are.
If any of the <code>years</code>, <code>months</code>, or <code>weeks</code> properties of either of the durations are nonzero, then the <code>relativeTo</code> option (and thus the <var>options</var> object) is <strong>required</strong>. This is because adding durations with years, months, or weeks requires a point on the calendar to figure out how long they are.
</div>

</dd>
Expand Down
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">
var isZero = time.blank;
var isZero = duration.blank;
</pre>


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

<h3 id="parameters">Parameters</h3>

<p>All parameters are {{optional_inline}} and specified as integers. Any missing or <code>undefined</code> numerical arguments are taken to be zero. Any non-integer numerical values is truncated to the nearest integer, towards zero. Non-zero values must all have the same sign.</p>
<p>All parameters are {{optional_inline}} and specified as integers. Any missing or <code>undefined</code> numerical arguments are taken to be zero. Any non-integer numerical value is truncated to the nearest integer, towards zero. Non-zero values must all have the same sign.</p>

<ul>
<li><code>years</code> – A number of years.</li>
Expand Down
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">
var days = time.days;
var days = duration.days;
</pre>


Expand Down
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">
var hours = time.hours;
var hours = duration.hours;
</pre>


Expand Down
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">
var microseconds = time.microseconds;
var microseconds = duration.microseconds;
</pre>


Expand Down
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">
var milliseconds = time.milliseconds;
var milliseconds = duration.milliseconds;
</pre>


Expand Down
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">
var minutes = time.minutes;
var minutes = duration.minutes;
</pre>


Expand Down
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">
var months = time.months;
var months = duration.months;
</pre>


Expand Down
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">
var nanoseconds = time.nanoseconds;
var nanoseconds = duration.nanoseconds;
</pre>


Expand Down
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">
var invertedTime = time.negated();
var invertedDuration = duration.negated();
</pre>


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 = Duration.round(<var>options</var>);
var newDuration = duration.round(<var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down
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">
var seconds = time.seconds;
var seconds = duration.seconds;
</pre>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ <h2 id="examples">Examples</h2>
d.sign; // => 1
</pre>
<pre class="brush: js">
d = Temporal.Duration.from(); // creates a Duration with all values at zero
d = new Temporal.Duration(); // creates a Duration with all values at zero
d.sign; // => 0
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ <h3 id="parameters">Parameters</h3>
<dt><code><var>duration</var></code></dt>
<dd>
<p>A <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object. If <code><var>duration</var></code> is not 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>. This allows for values such as an object with properties appropriate for a duration, such as <code>{ hours: 5, minutes: 30 }</code>; or a string value such as <code>PT5H30M</code>.</p>
<div class="warning">
If <var>duration</var> is larger than the original <code>Temporal.Duration</code> object, meaning the subtraction would result in a negative duration, the method will throw a <code>RangeError</code>.
</div>
</dd>

<dt><code><var>options</var></code> {{optional_inline}}(see note)</dt>
Expand Down
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">
var weeks = time.weeks;
var weeks = duration.weeks;
</pre>


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">
var newTime = Temporal.Duration.with(<var>newValues</var>);
var newDuration = duration.with(<var>newValues</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down Expand Up @@ -43,4 +43,3 @@ <h2 id="examples">Examples</h2>
duration = duration.with({ years, months });
// => P4Y2M50DT50H100M
</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">
var years = time.years;
var years = duration.years;
</pre>


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 represented by <code>PlainDate</code> and another date in the past, optionally rounds it, and returns it as a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object.</span> If the second date is later than the first, then the resulting duration will be negative. This method is similar to <code>{{jsxref('Temporal.PlainDate/until','Temporal.PlainDate.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 represented by <code>plainDate</code> and another date in the past, optionally rounds it, and returns it as a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object.</span> If the second date is later than the first, then the resulting duration will be negative. This method is similar to <code>{{jsxref('Temporal.PlainDate/until','Temporal.PlainDate.until()')}}</code>, but reversed.</p>
<div class="warning">
<p>Computing the difference between dates in different calendar systems is not supported. If you need to do this, choose the calendar in which the computation takes place by converting one of the dates using the method <code>{{jsxref('Temporal.PlainDate/withCalendar','withCalendar()')}}</code>.</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,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 @@ -53,7 +50,7 @@ <h3 id="parameters">Parameters</h3>

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

<p>A new <code>{{jsxref('Temporal/PlainDateTime','Temporal.PlainDateTime')}}</code> object representing the calendar date indicated by <code>PlainDateTime</code> plus <code><var>duration</var></code> If the result is earlier or later than the range of dates that <code>Temporal.PlainDateTime</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/PlainDateTime','Temporal.PlainDateTime')}}</code> object representing the calendar date indicated by <code><var>oldDateTime</var></code> plus <code><var>duration</var></code>. If the result is earlier or later than the range of dates that <code>Temporal.PlainDateTime</code> can represent (approximately half a million years centered on the Unix epoch), this method will throw a <code>RangeError</code> regardless of the 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 @@ -13,8 +13,8 @@
---
{{JSRef}}

<p class="summary"><span class="seoSummary">The <strong><code>compare()</code></strong> static method compares two dates and returns an integer indicating which comes before the other.</span></p>
<p>If you don’t care about the order in which the two date occur, but instead merely want to know if they’re the same or not, use <code>{{jsxref('Temporal/PlainDateTime/equals','Temporal.PlainDateTime.equals()')}}</code> instead.</p>
<p class="summary"><span class="seoSummary">The <strong><code>compare()</code></strong> static method compares two dates with times, and returns an integer indicating which comes before the other.</span></p>
<p>If you don’t care about the order in which the two dates and times occur, but instead merely want to know if they’re the same or not, use <code>{{jsxref('Temporal/PlainDateTime/equals','Temporal.PlainDateTime.equals()')}}</code> instead.</p>


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

<dt><code><var>isoDay</var></code> {{ optional_inline }}</dt>
<dt><code><var>isoDay</var></code></dt>
<dd><p>A number from 1 to 31 inclusive, identifying an ISO 8601 day.</p></dd>

<dt><code><var>isoHour</var></code> {{ optional_inline }}</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ <h3 id="parameters">Parameters</h3>
<li>Either a <code>month</code> or a <code>monthCode</code> property.</li>
<li>A <code>day</code> property.</li>
</ul>
<p>The object may also contain a <code>calendar</code> property; if omitted, the ISO 8601 calendar is used. The default values of any other omitted properties (e.g., {{jsxref('Temporal.PlainDateTime/minute','minute')}}) are determined by the calendar in use.</p>
<p>Any non-object, non-string value will be converted to a string, which is expected to be in ISO 8601 format. For other calendars, the calendar is also parsed in addition to year and month. Any other parts of the string, such as those relating to time or time zone, are optional and will be ignored. If the string is invalid according to ISO 8601, then a <code>RangeError</code> will be thrown regardless of the value of the <code>overflow</code> option (see next).</p>
<p>The object may also contain a <code>calendar</code> property; if omitted, the ISO 8601 calendar is used. The default value of any other omitted property (e.g., {{jsxref('Temporal.PlainDateTime/minute','minute')}}) is zero.</p>
<p>Any non-object, non-string value will be converted to a string, which is expected to be in ISO 8601 format. For other calendars, the calendar is also parsed in addition to the date and time. Any other parts of the string, such as a time zone, are optional and will be ignored. If the string is invalid according to ISO 8601, then a <code>RangeError</code> will be thrown regardless of the value of the <code>overflow</code> option (see next).</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 @@ -19,7 +19,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
var newTime = PlainDateTime.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>PlainDateTime</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.PlainDateTime/until','Temporal.PlainDateTime.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><var>dateTime</var></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.PlainDateTime/until','Temporal.PlainDateTime.until()')}}</code>, but reversed.</p>
<div class="warning">
<p>Computing the difference between dates and times in different calendar systems is not supported. If you need to do this, choose the calendar in which the computation takes place by converting one of the dates and times using the method <code>{{jsxref('Temporal.PlainDateTime/withCalendar','withCalendar()')}}</code>.</p>
</div>
Expand All @@ -29,7 +29,7 @@ <h3 id="parameters">Parameters</h3>

<dl>
<dt><code><var>otherDateTime</var></code></dt>
<dd>Another month as either a <code>{{jsxref('Temporal/PlainDateTime','Temporal.PlainDateTime')}}</code> object, or a value that can be converted to one as if passed to <code>{{jsxref('Temporal/PlainDateTime.from()','Temporal.PlainDateTime.from()')}}</code>.</dd>
<dd>Another date and time as either a <code>{{jsxref('Temporal/PlainDateTime','Temporal.PlainDateTime')}}</code> object, or a value that can be converted to one as if passed to <code>{{jsxref('Temporal/PlainDateTime.from()','Temporal.PlainDateTime.from()')}}</code>.</dd>
<dt><code><var>options</var></code> {{optional_inline}}</dt>
<dd>
<p>An object with properties defining how the rounding operation should be carried out. The allowed properties are:</p>
Expand All @@ -56,7 +56,7 @@ <h3 id="parameters">Parameters</h3>
</div>
</dd>
<dt><code>smallestUnit</code></dt>
<dd>A string defining the smallest unit of time allowed in the returned object. Valid values are the same as for <code>largestUnit</code>, except the default value is <code>'nanoseconds'</code>, which means no rounding will occur.</dd>
<dd>A string defining the smallest unit of time allowed in the returned object. Any fraction of time smaller than this will be rounded to the smallest unit. Valid values are the same as for <code>largestUnit</code>, except the default value is <code>'nanoseconds'</code>, which means no rounding will occur.</dd>
<dt><code>roundingIncrement</code></dt>
<dd>An integer defining the granularity of the rounding of the unit given by <code>smallestUnit</code>. The default is <code>1</code>.
<dt><code>roundingMode</code></dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,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 @@ -53,7 +50,7 @@ <h3 id="parameters">Parameters</h3>

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

<p>A new <code>{{jsxref('Temporal/PlainDateTime','Temporal.PlainDateTime')}}</code> object representing the calendar date indicated by <code>PlainDateTime</code> minus <code><var>duration</var></code>.
<p>A new <code>{{jsxref('Temporal/PlainDateTime','Temporal.PlainDateTime')}}</code> object representing the calendar date indicated by <code><var>oldDateTime</var></code> minus <code><var>duration</var></code>.
</p>

<h2 id="examples">Examples</h2>
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>until()</code></strong> method computes the elapsed time from the date and time represented by <code>PlainDateTime</code> until another date and time, optionally rounds it, and returns it as a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object.</span> If the second date and time is earlier than the first, then the resulting duration will be negative. This method is similar to <code>{{jsxref('Temporal.PlainDateTime/since','Temporal.PlainDateTime.since()')}}</code>, but reversed.</p>
<p class="summary"><span class="seoSummary">The <strong><code>until()</code></strong> method computes the elapsed time from the date and time represented by <code><var>dateTime</var></code> until another date and time, optionally rounds it, and returns it as a <code>{{jsxref('Temporal/Duration','Temporal.Duration')}}</code> object.</span> If the second date and time is earlier than the first, then the resulting duration will be negative. This method is similar to <code>{{jsxref('Temporal.PlainDateTime/since','Temporal.PlainDateTime.since()')}}</code>, but reversed.</p>
<div class="warning">
<p>Computing the difference between dates and times in different calendar systems is not supported. If you need to do this, choose the calendar in which the computation takes place by converting one of the dates and times using the method <code>{{jsxref('Temporal.PlainDateTime/withCalendar','withCalendar()')}}</code>.</p>
</div>
Expand All @@ -22,7 +22,7 @@
<h2 id="syntax">Syntax</h2>

<pre class="brush: js">
var timeBetween = PlainDateTime.until(<var>otherDateTime</var> [, <var>options</var>]);
var timeBetween = dateTime.until(<var>otherDateTime</var> [, <var>options</var>]);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down Expand Up @@ -56,7 +56,7 @@ <h3 id="parameters">Parameters</h3>
</div>
</dd>
<dt><code>smallestUnit</code></dt>
<dd>A string defining the smallest unit of time allowed in the returned object. Valid values are the same as for <code>largestUnit</code>, except the default value is <code>'nanoseconds'</code>, which means no rounding will occur.</dd>
<dd>A string defining the smallest unit of time allowed in the returned object. Any fraction of time smaller than this will be rounded to the smallest unit. Valid values are the same as for <code>largestUnit</code>, except the default value is <code>'nanoseconds'</code>, which means no rounding will occur.</dd>
<dt><code>roundingIncrement</code></dt>
<dd>An integer defining the granularity of the rounding of the unit given by <code>smallestUnit</code>. The default is <code>1</code>.
<dt><code>roundingMode</code></dt>
Expand Down
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">
var newDate = Temporal.PlainDateTime.with(<var>newValues</var>, <var>options</var>);
var newDateTime = dateTime.with(<var>newValues</var>, <var>options</var>);
</pre>

<h3 id="parameters">Parameters</h3>
Expand Down Expand Up @@ -51,7 +51,6 @@ <h2 id="return-value">Return value</h2>
<h2 id="examples">Examples</h2>

<pre class="brush: js">
date = Temporal.PlainDateTime.from('1995-12-07T03:24:30.000003500');
date.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035
dateTime = Temporal.PlainDateTime.from('1995-12-07T03:24:30.000003500');
dateTime.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035
</pre>

0 comments on commit 6fc83fc

Please sign in to comment.