deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

BREAKING(cli/unstable): remove `ProgressBarFormatter.styledTime` and use `DurationFormat`

Open timreichen opened this issue 6 months ago • 4 comments

We should not provide an opinionated time style in the ProgressBarFormatter object, we already provide a defaultFormatter which styles the time. Instead we should point to Intl.DurationFormat which allows for all kinds of styles.

timreichen avatar May 28 '25 21:05 timreichen

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.68%. Comparing base (3d44532) to head (6ddd319).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6692      +/-   ##
==========================================
- Coverage   94.70%   94.68%   -0.02%     
==========================================
  Files         567      567              
  Lines       46793    46797       +4     
  Branches     6582     6582              
==========================================
- Hits        44315    44312       -3     
- Misses       2436     2443       +7     
  Partials       42       42              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 28 '25 21:05 codecov[bot]

We should not provide an opinionated time style in the ProgressBarFormatter object, we already provide a defaultFormatter which styles the time.

I don't see this reasoning. MM:SS is probably most common format for indicating minutes and seconds, and styledTime is convenient shorthand for reusing that format when choosing different style as default formatter. Why do we need to remove it?

kt3k avatar May 29 '25 03:05 kt3k

This change doesn't format correctly. It puts everything under the seconds section.

new Intl.DurationFormat(undefined, {
  minutes: "2-digit",
  seconds:"2-digit",
  fractionalDigits: 0
})
  .format({milliseconds: Date.now()});
// "00:1748597655"

Screenshot 2025-05-30 at 19 35 27

BlackAsLight avatar May 30 '25 09:05 BlackAsLight

This change doesn't format correctly. It puts everything under the seconds section.

new Intl.DurationFormat(undefined, {
  minutes: "2-digit",
  seconds:"2-digit",
  fractionalDigits: 0
})
  .format({milliseconds: Date.now()});
// "00:1748597655"

Screenshot 2025-05-30 at 19 35 27

Good catch! I think this has to wait until Temporal is stable. Then that can be solved with Temporal.Duration.prototype.round(). Putting this as draft for now.

timreichen avatar May 30 '25 17:05 timreichen