tc39 / test262

Official ECMAScript Conformance Test Suite
Other
2.32k stars 459 forks source link

Relax whitespace requirements in Intl.DateTimeFormat.p.format timeStyle #4035

Closed ptomato closed 5 months ago

ptomato commented 5 months ago

This test uses formatToParts() to find out what kind of whitespace is used before the dayPeriod component, and expect that whitespace consistently.

I've observed an inconsistency between format() and formatToParts() on Node 20.7.0, so this method isn't reliable. An example:

const dtf = new Intl.DateTimeFormat('en-US', {timeStyle: 'short'});
dtf.formatToParts(0)[3].value.charCodeAt(0)  // 0x202F, narrow NBSP
dtf.format(0)[4].charCodeAt(0)  // 0x0020, space

This is conformant with the spec.

So, change the test to just allow any kind of whitespace. It'd be better to rewrite the test to rely less on particular output, but I'm not prepared to do that right now.

sffc commented 5 months ago

This is a known issue. https://issues.chromium.org/issues/40893567

Ms2ger commented 5 months ago

I'm not convinced this is conformant, given that both APIs call into PartitionDateTimePattern. At least, without evidence to the contrary, I would expect that PartitionDateTimePattern returns the same value for the same inputs

ptomato commented 5 months ago

That's a very good point, I'm convinced. Closing.

sffc commented 5 months ago

Yeah, the spec requires format and formatToParts to be the same. Browsers that don't currently do this are not conformant with that part of the spec.