mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-09 13:56:10 +00:00
34625ad1c4
Closes #7162
23 lines
464 B
QML
23 lines
464 B
QML
pragma Singleton
|
|
|
|
import QtQml 2.14
|
|
|
|
QtObject {
|
|
|
|
function fractionalPartLength(num) {
|
|
if (Number.isInteger(num))
|
|
return 0
|
|
|
|
return num.toString().split('.')[1].length
|
|
}
|
|
|
|
function numberToLocaleString(num, precision = -1, locale = null) {
|
|
locale = locale || Qt.locale()
|
|
|
|
if (precision === -1)
|
|
precision = fractionalPartLength(num)
|
|
|
|
return num.toLocaleString(locale, 'f', precision)
|
|
}
|
|
}
|