Skip to content

Commit

Permalink
Fix issue #78
Browse files Browse the repository at this point in the history
  • Loading branch information
rpbouman committed Apr 15, 2024
1 parent 68232ed commit 2db3eee
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/util/sql/SQLHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ function createNumberFormatter(fractionDigits){
};

var intFormatter, decimalSeparator;
intFormatter = new Intl.NumberFormat(locales, Object.assign({maximumFractionDigits: 0}, options));
if (fractionDigits){
intFormatter = new Intl.NumberFormat(locales, Object.assign({maximumFractionDigits: 0}, options));
options.minimumFractionDigits = localeSettings.minimumFractionDigits;
options.maximumFractionDigits = localeSettings.maximumFractionDigits;
}
var formatter = new Intl.NumberFormat(locales, options);
var formatter;
try {
formatter = new Intl.NumberFormat(locales, options);
}
catch (e){
// if the settings from the options somehow lead to an invalid format, we log it,
// but we will recover by creating a formatter that at least works.
console.error(`Error creating number formatter using locales ${JSON.stringify(locales)} and options ${JSON.stringify(options)}`);
console.error(e);
locales = navigator.languages;
options = {};
if (!fractionDigits){
options.minimumFractionDigits = 0;
}
console.error(`Falling back to default ${JSON.stringify(locales)} and options ${JSON.stringify(options)}`);
formatter = new Intl.NumberFormat(locales, options);
}
if (fractionDigits){
decimalSeparator = (new Intl.NumberFormat(locales, {minFractionDigits: 1})).formatToParts(123.456).find(function(part){
return part.type === 'decimal';
Expand Down

0 comments on commit 2db3eee

Please sign in to comment.