diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-09-02 22:51:37 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-09-03 14:59:14 +0300 |
commit | e55221e66f6e1bdbc8f24a2ad5b6b50a4013dd79 (patch) | |
tree | 0e13f52038ce2605314e1511f700a1df0ecb9138 | |
parent | 675329f357ce774da0e79cfd9c06a82898075b61 (diff) | |
download | qtlocation-mapboxgl-upstream/alexshalamov_expression_test_runner.tar.gz |
[darwin] Reset number formatter digits for currency styleupstream/alexshalamov_expression_test_runner
As we are using singleton formatter, fraction digits must be reset
when number formatter is used when initialized for decimal / currency
style.
-rw-r--r-- | platform/darwin/src/string_nsstring.mm | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/platform/darwin/src/string_nsstring.mm b/platform/darwin/src/string_nsstring.mm index 096ed2b212..382a2acf33 100644 --- a/platform/darwin/src/string_nsstring.mm +++ b/platform/darwin/src/string_nsstring.mm @@ -43,6 +43,10 @@ std::string formatNumber(double number, const std::string& localeId, const std:: numberFormatter.maximumFractionDigits = maxFractionDigits; numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; } else { + // Reset fraction digits to NSNumberFormatter's default values, so that the + // system will choose formatting based on number formatter locale. + numberFormatter.minimumFractionDigits = 0; + numberFormatter.maximumFractionDigits = 0; numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle; } NSString *formatted = [numberFormatter stringFromNumber:@(number)]; |