diff options
Diffstat (limited to 'Jel/Extensions/JellyfinKitExtensions.swift')
-rw-r--r-- | Jel/Extensions/JellyfinKitExtensions.swift | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Jel/Extensions/JellyfinKitExtensions.swift b/Jel/Extensions/JellyfinKitExtensions.swift new file mode 100644 index 0000000..197731c --- /dev/null +++ b/Jel/Extensions/JellyfinKitExtensions.swift @@ -0,0 +1,28 @@ +// +// JellyfinKitExtensions.swift +// Jel +// +// Created by zerocool on 12/24/23. +// + +import Foundation +import JellyfinKit + +extension BaseItemDto { + func getRuntime() -> String? { + let formatter: DateComponentsFormatter = { + let localFormatter = DateComponentsFormatter() + localFormatter.unitsStyle = .brief + localFormatter.allowedUnits = [.hour, .minute] + + return localFormatter + }() + + if let runTimeTicks = self.runTimeTicks { + let text = formatter.string(from: Double(runTimeTicks / 10_000_000)) + return text + } + + return nil + } +} |