mirror of
https://github.com/yattee/yattee.git
synced 2026-04-09 17:16:57 +00:00
Extract shared TimeInterval.formattedAsTimestamp replacing 8 identical formatTime/formattedTime implementations across player views. Remove unused currentTime parameter from GestureSeekPreviewView. Consolidate duplicated geometry math in MacOSControlBar into seekPreviewPosition().
17 lines
488 B
Swift
17 lines
488 B
Swift
import Foundation
|
|
|
|
extension TimeInterval {
|
|
/// Formats as "M:SS" or "H:MM:SS" when hours > 0.
|
|
var formattedAsTimestamp: String {
|
|
let totalSeconds = Int(max(0, self))
|
|
let hours = totalSeconds / 3600
|
|
let minutes = (totalSeconds % 3600) / 60
|
|
let seconds = totalSeconds % 60
|
|
|
|
if hours > 0 {
|
|
return String(format: "%d:%02d:%02d", hours, minutes, seconds)
|
|
}
|
|
return String(format: "%d:%02d", minutes, seconds)
|
|
}
|
|
}
|