mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix negative number formatting
This commit is contained in:
parent
2ab4af656b
commit
732a430119
@ -27,15 +27,19 @@ public func presentationStringsFormattedNumber(_ count: Int32, _ groupingSeparat
|
|||||||
if groupingSeparator.isEmpty || abs(count) < 1000 {
|
if groupingSeparator.isEmpty || abs(count) < 1000 {
|
||||||
return string
|
return string
|
||||||
} else {
|
} else {
|
||||||
var groupedString: String = ""
|
if count < 0 {
|
||||||
for i in 0 ..< Int(ceil(Double(string.count) / 3.0)) {
|
return "-\(presentationStringsFormattedNumber(abs(count), groupingSeparator))"
|
||||||
let index = string.count - Int(i + 1) * 3
|
} else {
|
||||||
if !groupedString.isEmpty {
|
var groupedString: String = ""
|
||||||
groupedString = groupingSeparator + groupedString
|
for i in 0 ..< Int(ceil(Double(string.count) / 3.0)) {
|
||||||
|
let index = string.count - Int(i + 1) * 3
|
||||||
|
if !groupedString.isEmpty {
|
||||||
|
groupedString = groupingSeparator + groupedString
|
||||||
|
}
|
||||||
|
groupedString = String(string[string.index(string.startIndex, offsetBy: max(0, index)) ..< string.index(string.startIndex, offsetBy: index + 3)]) + groupedString
|
||||||
}
|
}
|
||||||
groupedString = String(string[string.index(string.startIndex, offsetBy: max(0, index)) ..< string.index(string.startIndex, offsetBy: index + 3)]) + groupedString
|
return groupedString
|
||||||
}
|
}
|
||||||
return groupedString
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user