27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
let distanceDub = Double(distance) ?? 1.0
|
|
|
|
let convertedSeconds:Double = (Double(timeSeconds) ?? 0) * (1.666666666666666666666666)
|
|
let timeSecondsInt:Int = Int(timeSeconds) ?? 0
|
|
let timeSecondsUnderSixty:Int = (timeSecondsInt % 60)
|
|
|
|
let timeSecondsToMinutes:Int = (timeSecondsInt - timeSecondsUnderSixty) / 60
|
|
|
|
let timeMinutesDouble:Double = Double(timeMinutes) ?? 0.0
|
|
|
|
let timeMinutesInt:Int = (Int(timeMinutes) ?? 0) + (timeSecondsToMinutes)
|
|
let timeMinutesUnderSixty:Int = timeMinutesInt % 60
|
|
let timeMinutesToHours:Int = (timeMinutesInt - timeMinutesUnderSixty) / 60
|
|
|
|
let totalHours:Double = Double(timeMinutesToHours) + (Double(timeHours) ?? 0)
|
|
|
|
let leadingZeros:String = String(format: "%02d:%02d", timeMinutesUnderSixty, timeSecondsUnderSixty)
|
|
|
|
let actualTime:Double = timeMinutesDouble + (convertedSeconds / 100) + ((Double(timeHours) ?? 0) * 60)
|
|
let pace = actualTime / distanceDub
|
|
|
|
let paceWhole = (pace.rounded(.down))
|
|
let paceMinutes = paceWhole % 60
|
|
let paceHours = (paceWhole - paceMinutes) / 60
|
|
|
|
let paceString:String = String(format: "%.2f", pace)
|
|
let hoursFormatted:String = String(format: "%.0f", totalHours)
|