mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Video playback progress and restoring time for previously played
This commit is contained in:
17
Extensions/Double+Format.swift
Normal file
17
Extensions/Double+Format.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
import Foundation
|
||||
|
||||
extension Double {
|
||||
func formattedAsPlaybackTime() -> String? {
|
||||
guard !isZero else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let formatter = DateComponentsFormatter()
|
||||
|
||||
formatter.unitsStyle = .positional
|
||||
formatter.allowedUnits = self >= (60 * 60) ? [.hour, .minute, .second] : [.minute, .second]
|
||||
formatter.zeroFormattingBehavior = [.pad]
|
||||
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user