Skip to content

Commit bd6fdc7

Browse files
committed
Fix crash on truncating time
1 parent 158284e commit bd6fdc7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Shared/CommandParser.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ public class TimeParser {
291291
/// Truncates the time to the specified number of decimal places
292292
public class func truncateTime(_ time: TimeInterval, places: Int = 5) -> TimeInterval {
293293
let multiplier = (pow(10, places) as NSNumber).doubleValue
294-
295-
return (Double(Int(time * multiplier)) / multiplier)
294+
let fraction = (Double(Int(time.truncatingRemainder(dividingBy: 1) * multiplier)) / multiplier)
295+
return Double(Int(time)) + fraction
296296
}
297297

298298
/// Get duration in seconds from a string with the format HH:mm:ss or mm:ss

0 commit comments

Comments
 (0)