summaryrefslogtreecommitdiff
path: root/Jel/Extensions/BaseItemDtoExtensions.swift
blob: 27771bb33b4b078924525687ffdcd599d3cb179c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
//  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
  }
}

extension BaseItemDto {
  var overviewNL: String? {
    get {
      self.overview?.replacingOccurrences(of: "<br>", with: "\n")
    }
  }
}