-
Notifications
You must be signed in to change notification settings - Fork 12
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
signDisplay: missing option for a reasonable use-case #17
Labels
has-consensus
Has consensus and ready to implement
Comments
Thanks for the feedback! Maybe we could call this In the mean time, you can do class Formatter {
constructor(locale) {
this.negative = new Intl.NumberFormat(locale, { signDisplay: "exceptZero" });
this.positive = new Intl.NumberFormat(locale, { signDisplay: "auto" });
}
format(input) {
if (input < 0) return this.negative.format(input);
else return this.positive.format(input);
}
} |
Yes, either Thanks for the interim solution! |
Upstream issue: https://unicode-org.atlassian.net/browse/ICU-21484 |
2021-02-11: We will add this to the proposal as |
sffc
added
has-consensus
Has consensus and ready to implement
and removed
discuss
Needs discussion to make progress
labels
Feb 11, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use-case:
I'd like to round negative values but I don't want
-0
to be formatted into a string with "minus" sign i.e. I prefer"0"
instead of"-0"
For example:
The proposed spec for
signDisplay
supports these options:auto
,always
,never
andexceptZero
. But, none of them seem to produce the output desired for the use-case above - without compromising on something else.exceptZero
comes close, but in addition to removing the minus sign from-0
, it also adds a plus sign to positive numbers (as expected) which is not desired for the use-case above.I found this table containing examples of
signDisplay
options here: https://github.com/tc39/proposal-unified-intl-numberformat/blob/master/README.md#iii-sign-display. I was hoping to find an option that would produce-1 | 0 | 0 | 1 | NaN
, but such an option does not seem to exist.Am I missing something? What is the recommendation for handling the use-case above?
Thank you.
The text was updated successfully, but these errors were encountered: