-
Notifications
You must be signed in to change notification settings - Fork 633
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
@std/fmt/duration
: ignoreZeros
seems broken
#6304
Comments
This is the expected behavior. For |
I see. is there anything I can do to make it remove leading zeros too? perhaps a new option to do that? |
I'm not sure that option makes sense. If the leading zeros removed, there's no difference between "00:00:13:05" and "00:13:05:00" (both become "13:05", and I think that would be confusing) |
I see your point. But, wouldn't that be up to the developer to choose what is the right option for them to use? the library should allow the developer flexibility on what they want to do. I think a good implementation would be changing the api so the settings change from |
I'm skeptical that adding option is worth it as string method of javascript is enough flexible to support this kind of situation. If you prefer to strip the leading zeros you can do: format(785000, { style: "digital", ignoreZero: true }).replace(/^(00:)+/g, "") |
I think the current duration api is not very flexible. Intl.DurationFormat.prototype.format() is more flexible and supports locale, but sadly is not implemented in deno. The proper way of handling this would probably be to adapt the current implementation to mirror |
Describe the bug
the
ignoreZero
flag seems to ignore leading zeros:Steps to Reproduce
Expected behavior
expected: "13:05"
Environment
2.1.4
1.0.3
The text was updated successfully, but these errors were encountered: