Skip to content

Improve Intl.DurationFormat.format examples#28708

Merged
Josh-Cena merged 7 commits intomdn:mainfrom
ben-allen:update-intl-durationformat-format-method
Aug 28, 2023
Merged

Improve Intl.DurationFormat.format examples#28708
Josh-Cena merged 7 commits intomdn:mainfrom
ben-allen:update-intl-durationformat-format-method

Conversation

@ben-allen
Copy link
Copy Markdown
Contributor

…normative changes related to fractionalDigits option, clarify usage in general

Description

Motivation

Recent normative changes have altered the behaviour of `fractionalDigits. Intl.DurationFormat.format() now defaults to displaying however many digits are necessary to display all components, rather than defaulting to 0 fractional digits displayed.

Additional details

Related issues and pull requests

Relates to tc39/proposal-intl-duration-format#150

@ben-allen ben-allen requested a review from a team as a code owner August 23, 2023 03:58
@ben-allen ben-allen requested review from teoli2003 and removed request for a team August 23, 2023 03:58
@github-actions github-actions bot added the Content:JS JavaScript docs label Aug 23, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 23, 2023

Preview URLs

(comment last updated: 2023-08-28 13:45:03)

Copy link
Copy Markdown
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ben-allen thanks for the PR, but as a convention for Intl docs, the format pages are usually brief, and information about constructor options are included in the constructor page.

@ben-allen ben-allen force-pushed the update-intl-durationformat-format-method branch from 1716a59 to 6373c5d Compare August 23, 2023 08:44
@ben-allen ben-allen force-pushed the update-intl-durationformat-format-method branch from 6373c5d to cbce13f Compare August 23, 2023 08:54
@ben-allen
Copy link
Copy Markdown
Contributor Author

Updated to remove most of the examples, redundant explanations, and => in comments

Comment on lines -47 to -53
// With style set to "long"
new Intl.DurationFormat("en", { style: "long" }).format(duration);
// "1 year, 2 months, 3 weeks, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds, 8 microseconds, 9 nanoseconds"

// With style set to "narrow"
new Intl.DurationFormat("en", { style: "narrow" }).format(duration);
// "1y 2mo 3w 3d 4h 5m 6s 7ms 8μs 9ns"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why these are removed?

Copy link
Copy Markdown
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ben-allen One remaining question (#28708 (comment)) and then we can merge this. I think it's valuable to have comparisons of different styles under the en locale.

@Josh-Cena Josh-Cena changed the title substantial revision to Intl.DurationFormat.format Improve Intl.DurationFormat.format examples Aug 28, 2023
ben-allen and others added 2 commits August 28, 2023 06:41
…ionformat/format/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the update!

@Josh-Cena Josh-Cena merged commit 9dfeb26 into mdn:main Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:JS JavaScript docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants