Skip to content

Commit

Permalink
remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jkandzi committed Oct 10, 2017
1 parent f1d4eba commit ec7d93d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Sources/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func getTimeOfDay() -> Double {
extension Double {
func format(_ decimalPartLength: Int, minimumIntegerPartLength: Int = 0) -> String {
let value = String(self)
let components = value.characters
let components = value
.split() { $0 == "." }
.map { String($0) }

var integerPart = components.first ?? "0"

let missingLeadingZeros = minimumIntegerPartLength - integerPart.characters.count
let missingLeadingZeros = minimumIntegerPartLength - integerPart.count
if missingLeadingZeros > 0 {
integerPart = stringWithZeros(missingLeadingZeros) + integerPart
}
Expand All @@ -57,7 +57,7 @@ extension Double {
}

var decimalPlaces = components.last?.substringWithRange(0, end: decimalPartLength) ?? "0"
let missingPlaceCount = decimalPartLength - decimalPlaces.characters.count
let missingPlaceCount = decimalPartLength - decimalPlaces.count
decimalPlaces += stringWithZeros(missingPlaceCount)

return "\(integerPart).\(decimalPlaces)"
Expand All @@ -71,13 +71,13 @@ extension Double {
extension String {
func substringWithRange(_ start: Int, end: Int) -> String {
var end = end
if start < 0 || start > self.characters.count {
if start < 0 || start > self.count {
return ""
}
else if end < 0 || end > self.characters.count {
end = self.characters.count
else if end < 0 || end > self.count {
end = self.count
}
let range = self.characters.index(self.startIndex, offsetBy: start) ..< self.characters.index(self.startIndex, offsetBy: end)
let range = self.index(self.startIndex, offsetBy: start) ..< self.index(self.startIndex, offsetBy: end)
return String(self[range])
}
}

0 comments on commit ec7d93d

Please sign in to comment.