Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add leading zero to sub minute duration formatting #18

Closed
wants to merge 1 commit into from

Conversation

MikeDuister
Copy link

Currently values below 60 are formatted without a leading minute unit. This PR proposes that the minute counter should not collapse but should display "0", in turn the seconds counter must always be of double digits.

Formatting of values equal to or larger than 60 remains unchanged.

seconds previous formatting current formatting
0 0 0:00
10 10 0:10
60 1:00 1:00
3600 1:00:00 1:00:00

This change reflects the behaviour of SoundCloud

@lbrndnr
Copy link
Owner

lbrndnr commented Jul 2, 2023

Hi Mike,
Thanks for the pull request and sorry for the massive delay in response.
Leading zeros are definitely a good idea, but I think it's much easier/cleaner when implemented using a DateComponentsFormatter, as I did in Nutshell. If you still feel like fixing this, I'm very happy to merge it :)

@lbrndnr
Copy link
Owner

lbrndnr commented Jul 6, 2023

Oh just noticed you were already using DateComponentsFormatter, my bad. I have now fixed this in the latest commit using your code, but ditching the regular expression, just to keep it as simple as possible.

@lbrndnr lbrndnr closed this Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants