Fix timeline view time padding

This commit is contained in:
Arkadiusz Fal
2022-08-27 02:43:47 +02:00
parent 1cf37e5a00
commit 5b785cc9c2
3 changed files with 10 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
import Foundation
extension Double {
func formattedAsPlaybackTime(allowZero: Bool = false) -> String? {
func formattedAsPlaybackTime(allowZero: Bool = false, forceHours: Bool = false) -> String? {
guard allowZero || !isZero, isFinite else {
return nil
}
@@ -9,7 +9,7 @@ extension Double {
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .positional
formatter.allowedUnits = self >= (60 * 60) ? [.hour, .minute, .second] : [.minute, .second]
formatter.allowedUnits = self >= (60 * 60) || forceHours ? [.hour, .minute, .second] : [.minute, .second]
formatter.zeroFormattingBehavior = [.pad]
return formatter.string(from: self)