You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: files/en-us/web/javascript/reference/global_objects/intl/durationformat/format/index.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,12 +117,10 @@ It is possible to individually set the formatting of specific units by setting t
117
117
</tr>
118
118
</tbody>
119
119
</table>
120
-
121
120
122
121
If the formatting for `hours` or any smaller unit is set to `"2-digit"` or `"numeric"`, the formatting for all smaller units cannot be set to a value other than `"2-digit"` or `"numeric"`.
### Displaying subsecond units as fractions of a second
@@ -149,7 +152,7 @@ This setting can be overidden by setting `seconds` and the equivalent options fo
149
152
150
153
If the `style` option is not `"digital"` but the value for `seconds` is set to `"numeric"` or `"2-digits"`, then all units smaller than seconds will be displayed as fractions of seconds.
151
154
152
-
If the `style` option is not `"digital"` and `seconds` is not `"numeric"` or `"2-digit"`, but `milliseconds`, `microseconds`, or `nanoseconds` is set to `"numeric"`, then the value of that unit and all smaller units will be displayed as a fraction of the smallest unit that is set to any non-numeric style. If all sub-second values are set to "numeric", then those values will be displayed as a fraction of a second.
155
+
If the `style` option is not `"digital"` and `seconds` is not `"numeric"` or `"2-digit"`, but `milliseconds`, `microseconds`, or `nanoseconds` is set to `"numeric"`, then the value of that unit and all smaller units will be displayed as a fraction of the smallest unit that is set to any non-numeric style. If all sub-second values are set to "numeric", then those values will be displayed as a fraction of a second.
@@ -191,10 +194,9 @@ new Intl.DurationFormat('en', {style: "long", nanoseconds: "numeric"}).format(du
191
194
192
195
### Using the fractionalDigits option
193
196
194
-
If the other conditions for displaying units as fractions of a larger unit are met, and if the `fractionalDigits` option is set to any value between 0 and 9, inclusive of both, then that many fractional digits will be displayed. Rounding, if necessary, is toward 0. If `fractionalDigits` is not set, enough fractional digits (and no more than enough) will be used to fully display all components of the duration.
197
+
If the other conditions for displaying units as fractions of a larger unit are met, and if the `fractionalDigits` option is set to any value between 0 and 9, inclusive of both, then that many fractional digits will be displayed. Rounding, if necessary, is toward 0. If `fractionalDigits` is not set, enough fractional digits (and no more than enough) will be used to fully display all components of the duration.
0 commit comments