mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
still round numbers when not formatting them (#9653)
This commit is contained in:
parent
0ed5454d02
commit
5234e9bce5
@ -1,4 +1,5 @@
|
|||||||
import { FrontendLocaleData, NumberFormat } from "../../data/translation";
|
import { FrontendLocaleData, NumberFormat } from "../../data/translation";
|
||||||
|
import { round } from "../number/round";
|
||||||
|
|
||||||
export const numberFormatToLocale = (
|
export const numberFormatToLocale = (
|
||||||
localeOptions: FrontendLocaleData
|
localeOptions: FrontendLocaleData
|
||||||
@ -60,7 +61,12 @@ export const formatNumber = (
|
|||||||
).format(Number(num));
|
).format(Number(num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num.toString();
|
if (typeof num === "string") {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
return `${round(num, options?.maximumFractionDigits).toString()}${
|
||||||
|
options?.style === "currency" ? ` ${options.currency}` : ""
|
||||||
|
}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user