Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Next batch of editorial issues #3053

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,8 @@ export function DifferencePlainDateTimeWithRounding(
return { date: ZeroDateDuration(), time: TimeDuration.ZERO };
}

RejectDateTimeRange(isoDateTime1);
RejectDateTimeRange(isoDateTime2);
const duration = DifferenceISODateTime(isoDateTime1, isoDateTime2, calendar, largestUnit);

if (smallestUnit === 'nanosecond' && roundingIncrement === 1) return duration;
Expand All @@ -3500,6 +3502,8 @@ export function DifferencePlainDateTimeWithRounding(
export function DifferencePlainDateTimeWithTotal(isoDateTime1, isoDateTime2, calendar, unit) {
if (CompareISODateTime(isoDateTime1, isoDateTime2) == 0) return 0;

RejectDateTimeRange(isoDateTime1);
RejectDateTimeRange(isoDateTime2);
const duration = DifferenceISODateTime(isoDateTime1, isoDateTime2, calendar, unit);

if (unit === 'nanosecond') return duration.time.totalNs.toJSNumber();
Expand Down
2 changes: 1 addition & 1 deletion polyfill/lib/intl.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
EPOCHNANOSECONDS,
ISO_DATE,
ISO_DATE_TIME,
ORIGINAL,
SetSlot,
TIME,
CALENDAR
Expand All @@ -41,7 +42,6 @@ const MD = SymbolCtor('md');
const TIME_FMT = SymbolCtor('time');
const DATETIME = SymbolCtor('datetime');
const INST = SymbolCtor('instant');
const ORIGINAL = SymbolCtor('original');
const TZ_CANONICAL = SymbolCtor('timezone-canonical');
const TZ_ORIGINAL = SymbolCtor('timezone-original');
const CAL_ID = SymbolCtor('calendar-id');
Expand Down
4 changes: 4 additions & 0 deletions polyfill/lib/intrinsicclass.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SymbolFor,
SymbolToStringTag
} from './primordials.mjs';
import { GetSlot, ORIGINAL } from './slots.mjs';

import Call from 'es-abstract/2024/Call.js';

Expand All @@ -17,6 +18,9 @@ import ESGetIntrinsic from 'es-abstract/GetIntrinsic.js';
const INTRINSICS = {};

const customUtilInspectFormatters = {
['Intl.DateTimeFormat'](depth, options, inspect) {
return inspect(GetSlot(this, ORIGINAL), { depth, ...options });
},
['Temporal.Duration'](depth, options) {
const descr = options.stylize(this._repr_, 'special');
if (depth < 1) return descr;
Expand Down
3 changes: 3 additions & 0 deletions polyfill/lib/slots.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const MILLISECONDS = 'slot-milliseconds';
export const MICROSECONDS = 'slot-microseconds';
export const NANOSECONDS = 'slot-nanoseconds';

// Intl.DateTimeFormat
export const ORIGINAL = 'slot-original';

const slots = new WeakMapCtor();
export function CreateSlots(container) {
Call(WeakMapPrototypeSet, slots, [container, ObjectCreate(null)]);
Expand Down
6 changes: 3 additions & 3 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ <h1>
_required_: ~date~, ~time~, ~year-month~, ~month-day~, or ~any~,
_defaults_: ~date~, ~time~, ~year-month~, ~month-day~, ~zoned-date-time~, or ~all~,
_inherit_: ~all~ or ~relevant~,
): a DateTime Format Record
): a DateTime Format Record or *null*
</h1>
<dl class="header">
</dl>
Expand Down Expand Up @@ -864,8 +864,8 @@ <h1>
1. If _value_ is not *undefined*, then
1. Set _formatOptions_.[[&lt;_prop_>]] to _value_.
1. Set _needDefaults_ to *false*.
1. If _anyPresent_ is *true* and _needDefaults_ is *true*, return *null*.
1. If _needDefaults_ is *true*, then
1. If _anyPresent_ is *true* and _inherit_ is ~relevant~, return *null*.
1. For each property name _prop_ of _defaultOptions_, do
1. Set _formatOptions_.[[&lt;_prop_>]] to *"numeric"*.
1. If _defaults_ is ~zoned-date-time~, then
Expand Down Expand Up @@ -1651,7 +1651,7 @@ <h1><a href="https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-inst
<li><ins>[[TemporalPlainMonthDayFormat]] is a DateTime Format Record or *null*.</ins></li>
<li><ins>[[TemporalPlainTimeFormat]] is a DateTime Format Record or *null*.</ins></li>
<li><ins>[[TemporalPlainDateTimeFormat]] is a DateTime Format Record.</ins></li>
<li><ins>[[TemporalInstantFormat]] is a DateTime Format Records</ins></li>
<li><ins>[[TemporalInstantFormat]] is a DateTime Format Record.</ins></li>
</ul>

<p>Finally, Intl.DateTimeFormat instances have a [[BoundFormat]] internal slot that caches the function returned by the format accessor (<emu-xref href="#sec-intl.datetimeformat.prototype.format"></emu-xref>).</p>
Expand Down
2 changes: 2 additions & 0 deletions spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ <h1>
<emu-alg>
1. If CompareISODateTime(_isoDateTime1_, _isoDateTime2_) = 0, then
1. Return CombineDateAndTimeDuration(ZeroDateDuration(), 0).
1. If ISODateTimeWithinLimits(_isoDateTime1_) is *false* or ISODateTimeWithinLimits(_isoDateTime2_) is *false*, throw a *RangeError* exception.
1. Let _diff_ be DifferenceISODateTime(_isoDateTime1_, _isoDateTime2_, _calendar_, _largestUnit_).
1. If _smallestUnit_ is ~nanosecond~ and _roundingIncrement_ = 1, return _diff_.
1. Let _destEpochNs_ be GetUTCEpochNanoseconds(_isoDateTime2_).
Expand All @@ -1024,6 +1025,7 @@ <h1>
<emu-alg>
1. If CompareISODateTime(_isoDateTime1_, _isoDateTime2_) = 0, then
1. Return 0.
1. If ISODateTimeWithinLimits(_isoDateTime1_) is *false* or ISODateTimeWithinLimits(_isoDateTime2_) is *false*, throw a *RangeError* exception.
1. Let _diff_ be DifferenceISODateTime(_isoDateTime1_, _isoDateTime2_, _calendar_, _unit_).
1. If _unit_ is ~nanosecond~, return _diff_.[[Time]].
1. Let _destEpochNs_ be GetUTCEpochNanoseconds(_isoDateTime2_).
Expand Down
Loading