Skip to content

Commit c429eed

Browse files
committed
Editorial: DRY refactor of time formatting
This editorial commit removes redundant spec text dealing with time formatting: * Adds a new AO FormatTimeString, and calls it in TemporalTimeToString, TemporalDateTimeToString, and TimeString (the legacy date AO in 262). * Removes FormatSecondsStringPart and replaces it with a new AO FormatFractionalSeconds, and call it in FormatTimeString and TemporalDurationToString. The text of this new AO is aligned with similar text in GetOffsetStringFor in #2607. * Replaces sub-second formatting text in TemporalDurationToString with a call to FormatFractionalSeconds. * Aligns polyfill code to these spec changes. * Adjusts polyfill code in a few places to better match the spec. Note that this commit doesn't touch spec text for formatting time zone offsets because there are several in-flight PRs dealing with offsets and I wanted to keep this PR merge-conflict-free. But once those PRs land and the dust settles, then I'll send another editorial PR to DRY offset string formatting too, by using FormatTimeString to replace bespoke formatting text for offsets.
1 parent 8b80732 commit c429eed

File tree

10 files changed

+127
-109
lines changed

10 files changed

+127
-109
lines changed

polyfill/lib/ecmascript.mjs

Lines changed: 41 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const StringFromCharCode = String.fromCharCode;
2222
const StringPrototypeCharCodeAt = String.prototype.charCodeAt;
2323
const StringPrototypeMatchAll = String.prototype.matchAll;
2424
const StringPrototypeReplace = String.prototype.replace;
25+
const StringPrototypeSlice = String.prototype.slice;
2526

2627
import bigInt from 'big-integer';
2728
import callBound from 'call-bind/callBound';
@@ -2354,56 +2355,52 @@ export function ISOYearString(year) {
23542355
if (year < 0 || year > 9999) {
23552356
let sign = year < 0 ? '-' : '+';
23562357
let yearNumber = MathAbs(year);
2357-
yearString = sign + `000000${yearNumber}`.slice(-6);
2358+
yearString = sign + ToZeroPaddedDecimalString(yearNumber, 6);
23582359
} else {
2359-
yearString = `0000${year}`.slice(-4);
2360+
yearString = ToZeroPaddedDecimalString(year, 4);
23602361
}
23612362
return yearString;
23622363
}
23632364

23642365
export function ISODateTimePartString(part) {
2365-
return `00${part}`.slice(-2);
2366+
return ToZeroPaddedDecimalString(part, 2);
23662367
}
23672368

2368-
export function FormatSecondsStringPart(second, millisecond, microsecond, nanosecond, precision) {
2369-
if (precision === 'minute') return '';
2370-
2371-
const secs = `:${ISODateTimePartString(second)}`;
2372-
let fraction = millisecond * 1e6 + microsecond * 1e3 + nanosecond;
2373-
2369+
export function FormatFractionalSeconds(subSecondNanoseconds, precision) {
2370+
let fraction;
23742371
if (precision === 'auto') {
2375-
if (fraction === 0) return secs;
2376-
fraction = `${fraction}`.padStart(9, '0');
2377-
while (fraction[fraction.length - 1] === '0') fraction = fraction.slice(0, -1);
2372+
if (subSecondNanoseconds === 0) return '';
2373+
const fractionFullPrecision = ToZeroPaddedDecimalString(subSecondNanoseconds, 9);
2374+
// now remove any trailing zeroes
2375+
fraction = Call(StringPrototypeReplace, fractionFullPrecision, [/0+$/, '']);
23782376
} else {
2379-
if (precision === 0) return secs;
2380-
fraction = `${fraction}`.padStart(9, '0').slice(0, precision);
2377+
if (precision === 0) return '';
2378+
const fractionFullPrecision = ToZeroPaddedDecimalString(subSecondNanoseconds, 9);
2379+
fraction = Call(StringPrototypeSlice, fractionFullPrecision, [0, precision]);
23812380
}
2382-
return `${secs}.${fraction}`;
2381+
return `.${fraction}`;
2382+
}
2383+
2384+
export function FormatTimeString(hour, minute, second, subSecondNanoseconds, precision) {
2385+
let result = `${ISODateTimePartString(hour)}:${ISODateTimePartString(minute)}`;
2386+
if (precision === 'minute') return result;
2387+
2388+
result += `:${ISODateTimePartString(second)}`;
2389+
result += FormatFractionalSeconds(subSecondNanoseconds, precision);
2390+
return result;
23832391
}
23842392

23852393
export function TemporalInstantToString(instant, timeZone, precision) {
23862394
let outputTimeZone = timeZone;
23872395
if (outputTimeZone === undefined) outputTimeZone = 'UTC';
23882396
const dateTime = GetPlainDateTimeFor(outputTimeZone, instant, 'iso8601');
2389-
const year = ISOYearString(GetSlot(dateTime, ISO_YEAR));
2390-
const month = ISODateTimePartString(GetSlot(dateTime, ISO_MONTH));
2391-
const day = ISODateTimePartString(GetSlot(dateTime, ISO_DAY));
2392-
const hour = ISODateTimePartString(GetSlot(dateTime, ISO_HOUR));
2393-
const minute = ISODateTimePartString(GetSlot(dateTime, ISO_MINUTE));
2394-
const seconds = FormatSecondsStringPart(
2395-
GetSlot(dateTime, ISO_SECOND),
2396-
GetSlot(dateTime, ISO_MILLISECOND),
2397-
GetSlot(dateTime, ISO_MICROSECOND),
2398-
GetSlot(dateTime, ISO_NANOSECOND),
2399-
precision
2400-
);
2397+
const dateTimeString = TemporalDateTimeToString(dateTime, precision, 'never');
24012398
let timeZoneString = 'Z';
24022399
if (timeZone !== undefined) {
24032400
const offsetNs = GetOffsetNanosecondsFor(outputTimeZone, instant);
24042401
timeZoneString = FormatDateTimeUTCOffsetRounded(offsetNs);
24052402
}
2406-
return `${year}-${month}-${day}T${hour}:${minute}${seconds}${timeZoneString}`;
2403+
return `${dateTimeString}${timeZoneString}`;
24072404
}
24082405

24092406
function formatAsDecimalNumber(num) {
@@ -2449,20 +2446,11 @@ export function TemporalDurationToString(
24492446
(years === 0 && months === 0 && weeks === 0 && days === 0 && hours === 0 && minutes === 0) ||
24502447
precision !== 'auto'
24512448
) {
2452-
const fraction = MathAbs(ms.toJSNumber()) * 1e6 + MathAbs(µs.toJSNumber()) * 1e3 + MathAbs(ns.toJSNumber());
2453-
let decimalPart = ToZeroPaddedDecimalString(fraction, 9);
2454-
if (precision === 'auto') {
2455-
while (decimalPart[decimalPart.length - 1] === '0') {
2456-
decimalPart = decimalPart.slice(0, -1);
2457-
}
2458-
} else if (precision === 0) {
2459-
decimalPart = '';
2460-
} else {
2461-
decimalPart = decimalPart.slice(0, precision);
2462-
}
2463-
let secondsPart = seconds.abs().toString();
2464-
if (decimalPart) secondsPart += `.${decimalPart}`;
2465-
timePart += `${secondsPart}S`;
2449+
const secondsPart = formatAsDecimalNumber(seconds.abs());
2450+
const subSecondNanoseconds =
2451+
MathAbs(ms.toJSNumber()) * 1e6 + MathAbs(µs.toJSNumber()) * 1e3 + MathAbs(ns.toJSNumber());
2452+
const subSecondsPart = FormatFractionalSeconds(subSecondNanoseconds, precision);
2453+
timePart += `${secondsPart}${subSecondsPart}S`;
24662454
}
24672455
let result = `${sign < 0 ? '-' : ''}P${datePart}`;
24682456
if (timePart) result = `${result}T${timePart}`;
@@ -2506,14 +2494,13 @@ export function TemporalDateTimeToString(dateTime, precision, showCalendar = 'au
25062494
));
25072495
}
25082496

2509-
year = ISOYearString(year);
2510-
month = ISODateTimePartString(month);
2511-
day = ISODateTimePartString(day);
2512-
hour = ISODateTimePartString(hour);
2513-
minute = ISODateTimePartString(minute);
2514-
const seconds = FormatSecondsStringPart(second, millisecond, microsecond, nanosecond, precision);
2497+
const yearString = ISOYearString(year);
2498+
const monthString = ISODateTimePartString(month);
2499+
const dayString = ISODateTimePartString(day);
2500+
const subSecondNanoseconds = millisecond * 1e6 + microsecond * 1e3 + nanosecond;
2501+
const timeString = FormatTimeString(hour, minute, second, subSecondNanoseconds, precision);
25152502
const calendar = MaybeFormatCalendarAnnotation(GetSlot(dateTime, CALENDAR), showCalendar);
2516-
return `${year}-${month}-${day}T${hour}:${minute}${seconds}${calendar}`;
2503+
return `${yearString}-${monthString}-${dayString}T${timeString}${calendar}`;
25172504
}
25182505

25192506
export function TemporalMonthDayToString(monthDay, showCalendar = 'auto') {
@@ -2565,31 +2552,18 @@ export function TemporalZonedDateTimeToString(
25652552

25662553
const tz = GetSlot(zdt, TIME_ZONE);
25672554
const dateTime = GetPlainDateTimeFor(tz, instant, 'iso8601');
2568-
2569-
const year = ISOYearString(GetSlot(dateTime, ISO_YEAR));
2570-
const month = ISODateTimePartString(GetSlot(dateTime, ISO_MONTH));
2571-
const day = ISODateTimePartString(GetSlot(dateTime, ISO_DAY));
2572-
const hour = ISODateTimePartString(GetSlot(dateTime, ISO_HOUR));
2573-
const minute = ISODateTimePartString(GetSlot(dateTime, ISO_MINUTE));
2574-
const seconds = FormatSecondsStringPart(
2575-
GetSlot(dateTime, ISO_SECOND),
2576-
GetSlot(dateTime, ISO_MILLISECOND),
2577-
GetSlot(dateTime, ISO_MICROSECOND),
2578-
GetSlot(dateTime, ISO_NANOSECOND),
2579-
precision
2580-
);
2581-
let result = `${year}-${month}-${day}T${hour}:${minute}${seconds}`;
2555+
let dateTimeString = TemporalDateTimeToString(dateTime, precision, 'never');
25822556
if (showOffset !== 'never') {
25832557
const offsetNs = GetOffsetNanosecondsFor(tz, instant);
2584-
result += FormatDateTimeUTCOffsetRounded(offsetNs);
2558+
dateTimeString += FormatDateTimeUTCOffsetRounded(offsetNs);
25852559
}
25862560
if (showTimeZone !== 'never') {
25872561
const identifier = ToTemporalTimeZoneIdentifier(tz);
25882562
const flag = showTimeZone === 'critical' ? '!' : '';
2589-
result += `[${flag}${identifier}]`;
2563+
dateTimeString += `[${flag}${identifier}]`;
25902564
}
2591-
result += MaybeFormatCalendarAnnotation(GetSlot(zdt, CALENDAR), showCalendar);
2592-
return result;
2565+
dateTimeString += MaybeFormatCalendarAnnotation(GetSlot(zdt, CALENDAR), showCalendar);
2566+
return dateTimeString;
25932567
}
25942568

25952569
export function IsOffsetTimeZoneIdentifier(string) {

polyfill/lib/plaintime.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ function TemporalTimeToString(time, precision, options = undefined) {
4747
));
4848
}
4949

50-
hour = ES.ISODateTimePartString(hour);
51-
minute = ES.ISODateTimePartString(minute);
52-
const seconds = ES.FormatSecondsStringPart(second, millisecond, microsecond, nanosecond, precision);
53-
return `${hour}:${minute}${seconds}`;
50+
const subSecondNanoseconds = millisecond * 1e6 + microsecond * 1e3 + nanosecond;
51+
return ES.FormatTimeString(hour, minute, second, subSecondNanoseconds, precision);
5452
}
5553

5654
export class PlainTime {

spec/abstractops.html

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -680,22 +680,60 @@ <h1>
680680
</emu-alg>
681681
</emu-clause>
682682

683-
<emu-clause id="sec-temporal-formatsecondsstringpart" aoid="FormatSecondsStringPart">
684-
<h1>FormatSecondsStringPart ( _second_, _millisecond_, _microsecond_, _nanosecond_, _precision_ )</h1>
683+
<emu-clause id="sec-temporal-formatfractionalseconds" type="abstract operation">
684+
<h1>
685+
FormatFractionalSeconds (
686+
_subSecondNanoseconds_: an integer,
687+
_precision_: either an integer in the inclusive range 0 to 9 or *"auto"*
688+
): a String
689+
</h1>
690+
<dl class="header">
691+
<dt>description</dt>
692+
<dd>
693+
If _precision_ is zero, or if _precision_ is *"auto"* and _subSecondNanoseconds_ is zero, then an empty String will be returned.
694+
Otherwise, the output will be a decimal point followed by a sequence of fractional seconds digits, truncated to _precision_ digits or (if _precision_ is *"auto"*) to the last non-zero digit.
695+
</dd>
696+
</dl>
685697
<emu-alg>
686-
1. Assert: _second_, _millisecond_, _microsecond_, and _nanosecond_ are integers.
687-
1. If _precision_ is *"minute"*, return *""*.
688-
1. Let _secondsString_ be the string-concatenation of the code unit 0x003A (COLON) and ToZeroPaddedDecimalString(_second_, 2).
689-
1. Let _fraction_ be _millisecond_ &times; 10<sup>6</sup> + _microsecond_ &times; 10<sup>3</sup> + _nanosecond_.
690698
1. If _precision_ is *"auto"*, then
691-
1. If _fraction_ is 0, return _secondsString_.
692-
1. Set _fraction_ to ToZeroPaddedDecimalString(_fraction_, 9).
693-
1. Set _fraction_ to the longest possible substring of _fraction_ starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
699+
1. If _subSecondNanoseconds_ is 0, return the empty String.
700+
1. Let _fractionString_ be ToZeroPaddedDecimalString(_subSecondNanoseconds_, 9).
701+
1. Set _fractionString_ to the longest prefix of _fractionString_ ending with a code unit other than 0x0030 (DIGIT ZERO).
694702
1. Else,
695-
1. If _precision_ is 0, return _secondsString_.
696-
1. Set _fraction_ to ToZeroPaddedDecimalString(_fraction_, 9).
697-
1. Set _fraction_ to the substring of _fraction_ from 0 to _precision_.
698-
1. Return the string-concatenation of _secondsString_, the code unit 0x002E (FULL STOP), and _fraction_.
703+
1. If _precision_ is 0, return the empty String.
704+
1. Let _fractionString_ be ToZeroPaddedDecimalString(_subSecondNanoseconds_, 9).
705+
1. Set _fractionString_ to the substring of _fractionString_ from 0 to _precision_.
706+
1. Return the string-concatenation of the code unit 0x002E (FULL STOP) and _fractionString_.
707+
</emu-alg>
708+
</emu-clause>
709+
710+
<emu-clause id="sec-temporal-formattimestring" type="abstract operation">
711+
<h1>
712+
FormatTimeString (
713+
_hour_: an integer,
714+
_minute_: an integer,
715+
_second_: an integer,
716+
_subSecondNanoseconds_: an integer,
717+
_precision_: an integer in the inclusive range 0 to 9, *"minute"*, or *"auto"*
718+
): a String
719+
</h1>
720+
<dl class="header">
721+
<dt>description</dt>
722+
<dd>
723+
The output will be formatted like ±HH:MM if _precision_ is *"minute"*.
724+
Otherwise, the output will be formatted like ±HH:MM:SS if _precision_ is zero, or if _subSecondNanoseconds_ is zero and _precision is *"auto"*.
725+
Otherwise, the output will be formatted like ±HH:MM:SS.fff where "fff" is a sequence of fractional seconds digits, truncated to _precision_ digits or (if _precision_ is *"auto"*) to the last non-zero digit.
726+
</dd>
727+
</dl>
728+
<emu-alg>
729+
1. Let _hh_ be ToZeroPaddedDecimalString(_hour_, 2).
730+
1. Let _mm_ be ToZeroPaddedDecimalString(_minute_, 2).
731+
1. Let _result_ be the string-concatenation of _hh_, the code unit 0x003A (COLON), and _mm_.
732+
1. If _precision_ is *"minute"*, return _result_.
733+
1. Let _ss_ be ToZeroPaddedDecimalString(_second_, 2).
734+
1. Let _subSecondsPart_ be FormatFractionalSeconds(_subSecondNanoseconds_, _precision_).
735+
1. Set _result_ to the string-concatenation of _result_, the code unit 0x003A (COLON), _ss_, and _subSecondsPart_.
736+
1. Return _result_.
699737
</emu-alg>
700738
</emu-clause>
701739

spec/duration.html

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,18 +1936,10 @@ <h1>
19361936
1. Let _zeroMinutesAndHigher_ be *false*.
19371937
1. If _years_ = 0, and _months_ = 0, and _weeks_ = 0, and _days_ = 0, and _hours_ = 0, and _minutes_ = 0, set _zeroMinutesAndHigher_ to *true*.
19381938
1. If _nonzeroSecondsAndLower_ is *true*, or _zeroMinutesAndHigher_ is *true*, or _precision_ is not *"auto"*, then
1939-
1. Let _fraction_ be abs(_milliseconds_) &times; 10<sup>6</sup> + abs(_microseconds_) &times; 10<sup>3</sup> + abs(_nanoseconds_).
1940-
1. Let _decimalPart_ be ToZeroPaddedDecimalString(_fraction_, 9).
1941-
1. If _precision_ is *"auto"*, then
1942-
1. Set _decimalPart_ to the longest possible substring of _decimalPart_ starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
1943-
1. Else if _precision_ = 0, then
1944-
1. Set _decimalPart_ to *""*.
1945-
1. Else,
1946-
1. Set _decimalPart_ to the substring of _decimalPart_ from 0 to _precision_.
19471939
1. Let _secondsPart_ be abs(_seconds_) formatted as a decimal number.
1948-
1. If _decimalPart_ is not *""*, then
1949-
1. Set _secondsPart_ to the string-concatenation of _secondsPart_, the code unit 0x002E (FULL STOP), and _decimalPart_.
1950-
1. Set _timePart_ to the string concatenation of _timePart_, _secondsPart_, and the code unit 0x0053 (LATIN CAPITAL LETTER S).
1940+
1. Let _subSecondNanoseconds_ be abs(_milliseconds_) &times; 10<sup>6</sup> + abs(_microseconds_) &times; 10<sup>3</sup> + abs(_nanoseconds_).
1941+
1. Let _subSecondsPart_ be FormatFractionalSeconds(_subSecondNanoseconds_, _precision_).
1942+
1. Set _timePart_ to the string concatenation of _timePart_, _secondsPart_, _subSecondsPart_, and the code unit 0x0053 (LATIN CAPITAL LETTER S).
19511943
1. Let _signPart_ be the code unit 0x002D (HYPHEN-MINUS) if _sign_ &lt; 0, and otherwise the empty String.
19521944
1. Let _result_ be the string concatenation of _signPart_, the code unit 0x0050 (LATIN CAPITAL LETTER P) and _datePart_.
19531945
1. If _timePart_ is not *""*, then

spec/mainadditions.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,25 @@ <h1>
390390

391391
<p>[...]</p>
392392

393+
<emu-clause id="sec-timestring" type="abstract operation">
394+
<h1>
395+
TimeString (
396+
_tv_: a Number, but not *NaN*,
397+
): a String
398+
</h1>
399+
<dl class="header">
400+
</dl>
401+
<emu-alg>
402+
1. <del>Let _hour_ be ToZeroPaddedDecimalString(ℝ(HourFromTime(_tv_)), 2).</del>
403+
1. <del>Let _minute_ be ToZeroPaddedDecimalString(ℝ(MinFromTime(_tv_)), 2).</del>
404+
1. <del>Let _second_ be ToZeroPaddedDecimalString(ℝ(SecFromTime(_tv_)), 2).</del>
405+
1. <ins>Let _timeString_ be FormatTimeString(ℝ(HourFromTime(_tv_)), ℝ(MinFromTime(_tv_)), ℝ(SecFromTime(_tv_)), 0, 0).</ins>
406+
1. Return the string-concatenation of _timeString_, the code unit 0x0020 (SPACE), and *"GMT"*.
407+
</emu-alg>
408+
</emu-clause>
409+
410+
<p>[...]</p>
411+
393412
<emu-clause id="sec-timezoneestring" type="abstract operation">
394413
<h1>
395414
TimeZoneString (

spec/plaindate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ <h1>TemporalDateToString ( _temporalDate_, _showCalendar_ )</h1>
928928
<emu-alg>
929929
1. Assert: Type(_temporalDate_) is Object.
930930
1. Assert: _temporalDate_ has an [[InitializedTemporalDate]] internal slot.
931-
1. Let _year_ be ! PadISOYear(_temporalDate_.[[ISOYear]]).
931+
1. Let _year_ be PadISOYear(_temporalDate_.[[ISOYear]]).
932932
1. Let _month_ be ToZeroPaddedDecimalString(_temporalDate_.[[ISOMonth]], 2).
933933
1. Let _day_ be ToZeroPaddedDecimalString(_temporalDate_.[[ISODay]], 2).
934934
1. Let _calendar_ be ? MaybeFormatCalendarAnnotation(_temporalDate_.[[Calendar]], _showCalendar_).

spec/plaindatetime.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -993,14 +993,13 @@ <h1>
993993
<h1>TemporalDateTimeToString ( _isoYear_, _isoMonth_, _isoDay_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _calendar_, _precision_, _showCalendar_ )</h1>
994994
<emu-alg>
995995
1. Assert: _isoYear_, _isoMonth_, _isoDay_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, and _nanosecond_ are integers.
996-
1. Let _year_ be ! PadISOYear(_isoYear_).
997-
1. Let _month_ be ToZeroPaddedDecimalString(_isoMonth_, 2).
998-
1. Let _day_ be ToZeroPaddedDecimalString(_isoDay_, 2).
999-
1. Let _hour_ be ToZeroPaddedDecimalString(_hour_, 2).
1000-
1. Let _minute_ be ToZeroPaddedDecimalString(_minute_, 2).
1001-
1. Let _seconds_ be ! FormatSecondsStringPart(_second_, _millisecond_, _microsecond_, _nanosecond_, _precision_).
996+
1. Let _yearString_ be PadISOYear(_isoYear_).
997+
1. Let _monthString_ be ToZeroPaddedDecimalString(_isoMonth_, 2).
998+
1. Let _dayString_ be ToZeroPaddedDecimalString(_isoDay_, 2).
999+
1. Let _subSecondNanoseconds_ be _millisecond_ &times; 10<sup>6</sup> + _microsecond_ &times; 10<sup>3</sup> + _nanosecond_.
1000+
1. Let _timeString_ be FormatTimeString(_hour_, _minute_, _second_, _subSecondNanoseconds_, _precision_).
10021001
1. Let _calendarString_ be ? MaybeFormatCalendarAnnotation(_calendar_, _showCalendar_).
1003-
1. Return the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), _month_, the code unit 0x002D (HYPHEN-MINUS), _day_, 0x0054 (LATIN CAPITAL LETTER T), _hour_, the code unit 0x003A (COLON), _minute_, _seconds_, and _calendarString_.
1002+
1. Return the string-concatenation of _yearString_, the code unit 0x002D (HYPHEN-MINUS), _monthString_, the code unit 0x002D (HYPHEN-MINUS), _dayString_, 0x0054 (LATIN CAPITAL LETTER T), _timeString_, and _calendarString_.
10041003
</emu-alg>
10051004
</emu-clause>
10061005

spec/plainmonthday.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ <h1>TemporalMonthDayToString ( _monthDay_, _showCalendar_ )</h1>
437437
1. Let _result_ be the string-concatenation of _month_, the code unit 0x002D (HYPHEN-MINUS), and _day_.
438438
1. Let _calendarIdentifier_ be ? ToTemporalCalendarIdentifier(_monthDay_.[[Calendar]]).
439439
1. If _showCalendar_ is one of *"always"* or *"critical"*, or if _calendarIdentifier_ is not *"iso8601"*, then
440-
1. Let _year_ be ! PadISOYear(_monthDay_.[[ISOYear]]).
440+
1. Let _year_ be PadISOYear(_monthDay_.[[ISOYear]]).
441441
1. Set _result_ to the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), and _result_.
442442
1. Let _calendarString_ be FormatCalendarAnnotation(_calendarIdentifier_, _showCalendar_).
443443
1. Set _result_ to the string-concatenation of _result_ and _calendarString_.

spec/plaintime.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,8 @@ <h1>
813813
<h1>TemporalTimeToString ( _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _precision_ )</h1>
814814
<emu-alg>
815815
1. Assert: _hour_, _minute_, _second_, _millisecond_, _microsecond_ and _nanosecond_ are integers.
816-
1. Let _hour_ be ToZeroPaddedDecimalString(_hour_, 2).
817-
1. Let _minute_ be ToZeroPaddedDecimalString(_minute_, 2).
818-
1. Let _seconds_ be ! FormatSecondsStringPart(_second_, _millisecond_, _microsecond_, _nanosecond_, _precision_).
819-
1. Return the string-concatenation of _hour_, the code unit 0x003A (COLON), _minute_, and _seconds_.
816+
1. Let _subSecondNanoseconds_ be _millisecond_ &times; 10<sup>6</sup> + _microsecond_ &times; 10<sup>3</sup> + _nanosecond_.
817+
1. Return FormatTimeString(_hour_, _minute_, _second_, _subSecondNanoseconds_, _precision_).
820818
</emu-alg>
821819
</emu-clause>
822820

0 commit comments

Comments
 (0)