Skip to content

DateTimeFormat fractionalSecondDigits: conflict between MDN and spec #590

@justingrant

Description

@justingrant

MDN shows that 0 is a valid value for the fractionalSecondDigits. The spec (and Chrome) throws when zero is passed for this option. Here's the docs:

image

I assume this was thought through and there's a good reason for zero being excluded in the 402 spec. Why was the reason?

FWIW, Temporal allows zero for this option, so regardless of whether zero is allowed or not, we should probably align across Temporal and 402. AFAIK, there's already a plan to expand this option to allow for nanoseconds precision, so as part of those changes I'd vote for allowing zero because it seems like a valid choice, but if you disagree then let's discuss. There's also an 'auto' option allowed on the Temporal side.

Here's the TS declaration of this on in Temporal:

fractionalSecondDigits?: 'auto' | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;

Here's a repro to see the error

new Intl.DateTimeFormat(
  'en-us', 
  { hour: 'numeric', minute: 'numeric', second: 'numeric', fractionalSecondDigits: 0 }
).format(new Date())
// MDN: OK
// Spec and Chrome: RangeError: fractionalSecondDigits value is out of range.

Metadata

Metadata

Assignees

Labels

c: datetimeComponent: dates, times, timezoness: help wantedStatus: help wanted; needs proposal champion

Type

No type

Projects

Status

Previously Discussed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions