Skip to content

Commit d7f5d31

Browse files
justingrantptomato
authored andcommitted
Support offset time zones in Intl.DTF polyfill
In Node 23, offset time zone IDs are now supported by `Intl.DateTimeFormat`. This commit changes the polyfill to handle these IDs.
1 parent 9999373 commit d7f5d31

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

polyfill/lib/intl.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ function createDateTimeFormat(dtf, locale, options) {
168168
SetSlot(dtf, TZ_ORIGINAL, ro.timeZone);
169169
} else {
170170
const id = ES.ToString(timeZoneOption);
171-
if (ES.IsOffsetTimeZoneIdentifier(id)) {
172-
// Note: https://github.com/tc39/ecma402/issues/683 will remove this
173-
throw new RangeErrorCtor('Intl.DateTimeFormat does not currently support offset time zones');
171+
if (id.startsWith('−')) {
172+
// The initial (Node 23) implementation of offset time zones allowed use
173+
// of the Unicode minus sign, which was disallowed by a later spec change.
174+
throw new RangeError('Unicode minus (U+2212) is not supported in time zone offsets');
174175
}
175-
const record = ES.GetAvailableNamedTimeZoneIdentifier(id);
176-
if (!record) throw new RangeErrorCtor(`Intl.DateTimeFormat formats built-in time zones, not ${id}`);
177-
SetSlot(dtf, TZ_ORIGINAL, record.identifier);
176+
// store a normalized identifier
177+
SetSlot(dtf, TZ_ORIGINAL, ES.ToTemporalTimeZoneIdentifier(id));
178178
}
179179
}
180180

polyfill/test/expected-failures.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ staging/Intl402/Temporal/old/time-toLocaleString.js
77
intl402/DateTimeFormat/prototype/format/temporal-objects-resolved-time-zone.js
88
intl402/DateTimeFormat/prototype/format/timedatestyle-en.js
99

10-
# These are caught by the default test glob, but are unrelated to Temporal.
11-
# They rely on Intl.DateTimeFormat supporting offset time zones.
12-
intl402/DateTimeFormat/prototype/format/offset-timezone-gmt-same.js
13-
intl402/DateTimeFormat/prototype/formatToParts/offset-timezone-correct.js
14-
intl402/DateTimeFormat/prototype/resolvedOptions/offset-timezone-basic.js
15-
intl402/DateTimeFormat/prototype/resolvedOptions/offset-timezone-change.js
16-
1710
# Temporal test262 runner does not support $262.createRealm()
1811
intl402/DateTimeFormat/proto-from-ctor-realm.js
1912

0 commit comments

Comments
 (0)