You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to DaysUntil, here we use the already-existing MakeDay operation
in ECMA-262 to convert ISO year/month/day to days since epoch, which can
be subtracted directly.
The algorithm is essentially doing what it already did: calculating a
number of days, and converting to weeks if necessary. However, it now does
so without having to swap the order of the dates and negate the result if
the second is earlier than the first.
(Unfortunately, the first half of DifferenceISODate, to compute the
difference in months, is still hard-to-read. I'll keep looking for a way
to simplify this.)
Copy file name to clipboardExpand all lines: spec/plaindate.html
+11-20Lines changed: 11 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -707,18 +707,17 @@ <h1>
707
707
_y2_: an integer,
708
708
_m2_: an integer,
709
709
_d2_: an integer,
710
-
_largestUnit_: a String,
711
-
)
710
+
_largestUnit_: *"year"*, *"month"*, *"week"*, or *"day"*,
711
+
): a Date Duration Record
712
712
</h1>
713
713
<dlclass="header">
714
714
<dt>description</dt>
715
715
<dd>
716
-
It returns a Date Duration Record with the elapsed duration from a first date until a second date, according to the reckoning of the ISO 8601 calendar.
716
+
The return value is the elapsed duration from a first date until a second date, according to the reckoning of the ISO 8601 calendar.
717
717
No fields larger than _largestUnit_ will be non-zero in the resulting Date Duration Record.
718
718
</dd>
719
719
</dl>
720
720
<emu-alg>
721
-
1.Assert:_largestUnit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*.
722
721
1. If _largestUnit_ is *"year"* or *"month"*, then
723
722
1. Let _sign_ be -(! CompareISODate(_y1_, _m1_, _d1_, _y2_, _m2_, _d2_)).
724
723
1. If _sign_ is 0, return ! CreateDateDurationRecord(0, 0, 0, 0).
0 commit comments