tc39 / test262

Official ECMAScript Conformance Test Suite
Other
2.38k stars 461 forks source link

test formatting when microseconds or nanoseconds are the first numeric-styled unit #4034

Closed ben-allen closed 7 months ago

ben-allen commented 7 months ago

If microseconds are the first numeric-styled unit, they should be displayed as a fractional component of milliseconds. Likewise, if nanoseconds is the first numeric-styled unit, they should be displayed as a fractional component of microseconds.

ben-allen commented 7 months ago

Added the padding for the fractional components -- good catch!

With regard to testing for "fractional" style: The "fractional" style is never directly used by users, who only have "numeric" available, and so we don't need to have tests for it. The internal-use-only "fractional" style exists for a couple of different reasons:

  1. The "numeric" style means two dramatically different things, depending on the unit to which it's applied. If the unit is hours, minutes, or seconds, it means something like "format this as on a digital clock", when it's a subsecond unit it means "make this a fractional component of the previously displayed unit". Using the name "fractional" simplifies the logic for formatting numeric units, particularly once https://github.com/tc39/proposal-intl-duration-format/pull/188 lands
  2. A hypothetical DFv2 could allow users to style durations with fractional components of minutes or hours as well as seconds, milliseconds, and microseconds. In this case making "fractional" an actual user-specifiable style rather than just something for internal use would be necessary.