From 9d1eeeb42af761f96e6e36fc785fa6910284f0a9 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 8 Oct 2024 12:43:25 -0700 Subject: [PATCH] Editorial: Inline TimeDurationSeconds and TimeDurationSubseconds We originally planned to convert time durations to a record with a seconds and subseconds field, but that was never necessary. Now that they are just a mathematical value, we don't need to access them through these seconds and subseconds operations. See: #2953 --- spec/duration.html | 36 +++--------------------------------- spec/plaintime.html | 5 ++--- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/spec/duration.html b/spec/duration.html index 44eb8c40a..fe9f01189 100644 --- a/spec/duration.html +++ b/spec/duration.html @@ -909,7 +909,7 @@

1. Let _internalDuration_ be ToInternalDurationRecordWith24HourDays(_duration_). - 1. Let _days_ be truncate(TimeDurationSeconds(_internalDuration_.[[Time]]) / 86400). + 1. Let _days_ be truncate(_internalDuration_.[[Time]] / nsPerDay). 1. Return ? CreateDateDurationRecord(_internalDuration_.[[Date]].[[Years]], _internalDuration_.[[Date]].[[Months]], _internalDuration_.[[Date]].[[Weeks]], _days_). @@ -1458,21 +1458,6 @@

- -

- TimeDurationSeconds ( - _d_: a time duration, - ): an integer in the interval from -253 (exclusive) to 253 (exclusive) -

-
-
description
-
It returns the integer number of seconds in _d_.
-
- - 1. Return truncate(_d_ / 109). - -
-

TimeDurationSign ( @@ -1490,21 +1475,6 @@

- -

- TimeDurationSubseconds ( - _d_: a time duration, - ): an integer in the interval from -109 (exclusive) to 109 (exclusive) -

-
-
description
-
It returns the integer number of nanoseconds in the subsecond part of _d_.
-
- - 1. Return remainder(_d_, 109). - -
-

SubtractTimeDuration ( @@ -1965,8 +1935,8 @@

1. If DefaultTemporalLargestUnit(_duration_) is ~second~, ~millisecond~, ~microsecond~, or ~nanosecond~, set _zeroMinutesAndHigher_ to *true*. 1. Let _secondsDuration_ be TimeDurationFromComponents(0, 0, _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]). 1. If _secondsDuration_ ≠ 0, or _zeroMinutesAndHigher_ is *true*, or _precision_ is not ~auto~, then - 1. Let _secondsPart_ be abs(TimeDurationSeconds(_secondsDuration_)) formatted as a decimal number. - 1. Let _subSecondsPart_ be FormatFractionalSeconds(abs(TimeDurationSubseconds(_secondsDuration_)), _precision_). + 1. Let _secondsPart_ be abs(truncate(_secondsDuration_ / 109)) formatted as a decimal number. + 1. Let _subSecondsPart_ be FormatFractionalSeconds(abs(remainder(_secondsDuration_, 109)), _precision_). 1. Set _timePart_ to the string concatenation of _timePart_, _secondsPart_, _subSecondsPart_, and the code unit 0x0053 (LATIN CAPITAL LETTER S). 1. Let _signPart_ be the code unit 0x002D (HYPHEN-MINUS) if _sign_ < 0, and otherwise the empty String. 1. Let _result_ be the string concatenation of _signPart_, the code unit 0x0050 (LATIN CAPITAL LETTER P) and _datePart_. diff --git a/spec/plaintime.html b/spec/plaintime.html index 9d519ea30..fff59403e 100644 --- a/spec/plaintime.html +++ b/spec/plaintime.html @@ -862,9 +862,8 @@

- 1. Let _second_ be _time_.[[Second]] + TimeDurationSeconds(_timeDuration_). - 1. Let _nanosecond_ be _time_.[[Nanosecond]] + TimeDurationSubseconds(_timeDuration_). - 1. Return BalanceTime(_time_.[[Hour]], _time_.[[Minute]], _second_, _time_.[[Millisecond]], _time_.[[Microsecond]], _nanosecond_). + 1. Return BalanceTime(_time_.[[Hour]], _time_.[[Minute]], _time_.[[Second]], _time_.[[Millisecond]], _time_.[[Microsecond]], _time_.[[Nanosecond]] + _timeDuration_). + 1. NOTE: If using floating points to implement this operation, add the time components separately before balancing to avoid errors with unsafe integers.