-
Notifications
You must be signed in to change notification settings - Fork 1.2k
SR-7481: NumberFormatter inconsistency on Linux #1530
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
Conversation
- For the numberStyle .currency, use a minimumIntegerDigits of 1. - If minimumIntegerDigits is set to any value (including 0) before the numberStyle is set, preserve the original value.
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, also adding @itaiferber
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, though if we care about 100% consistency, there are some other cases to take care of
Foundation/NumberFormatter.swift
Outdated
@@ -190,12 +190,15 @@ open class NumberFormatter : Formatter { | |||
case .currency, .currencyPlural, .currencyISOCode, .currencyAccounting: | |||
_usesSignificantDigits = false | |||
_usesGroupingSeparator = true | |||
if _minimumIntegerDigits == nil { | |||
_minimumIntegerDigits = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I believe this value is 0
for .currencyPlural
on Darwin. Likewise, I see the value being 1
for .percent
, which I believe is falling into the default
case (along with .scientific
, which is correctly 0
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add some more test cases to compare against native Foundation and fix up these others.
- Fix rawValue for Style.{currencyISOCode,currencyPlural,currencyAccounting} - Fix minimumIntegerDigits for .currencyPlural - Fix usesSignificantDigits, minimumIntegerDigits and groupingSize for .percent
@itaiferber I added some more tests for all of the number styles and fixed an issue with the rawValues being wrong for Definitely needs more tests for the other properties but I think this fixes the Validated against 10.13.4's Foundation. |
@swift-ci please test |
1 similar comment
@swift-ci please test |
@spevans LGTM, thanks! Good catch on the |
@swift-ci please test and merge |
For the numberStyle .currency, use a minimumIntegerDigits of 1.
If minimumIntegerDigits is set to any value (including 0) before
the numberStyle is set, preserve the original value.