File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,17 +126,18 @@ class FitnessCalculator {
126126 }
127127
128128 func secondsForDistance( distance: Double , pace: Pace = . avgWalk) -> Int {
129- let speed : Double = personalizationController. units == . imperial ? pace. milesPerHour : ( pace. kmPerHour * 1.60934 )
129+ // Convert kph to mph if needed
130+ let speed : Double = personalizationController. units == . imperial ? pace. milesPerHour : ( pace. kmPerHour / 1.609 )
130131
131132 return Int ( ceil ( ( distance / speed) * 60 * 60 ) )
132133 }
133134
134135 func secondsFormatted( seconds: Int , full: Bool = false ) -> String {
135- let hours = seconds / 3600
136+ let hours = Double ( seconds) / 3600.0
136137 let minutes = ( seconds % 3600 ) / 60
137138
138- if hours > 0 {
139- return " \( String ( format: " %.1f " , hours) ) \( full ? " hour " : " hr " ) \( hours == 1 ? " " : " s " ) "
139+ if hours >= 1 {
140+ return " \( String ( format: " %.2f " , hours) ) \( full ? " hour " : " hr " ) \( hours == 1 ? " " : " s " ) "
140141 } else if minutes > 0 {
141142 return " \( minutes) \( full ? " minute " : " min " ) \( minutes == 1 ? " " : " s " ) "
142143 } else {
You can’t perform that action at this time.
0 commit comments