import Foundation extension TimeInterval { func duration(locale: Locale) -> String { let totalMinutes = Int((self / 60).rounded(to: 5)) let hours = totalMinutes / 60 let minutes = totalMinutes % 60 let suffix = locale.identifier.hasPrefix("de") ? "Std" : "h" return String(format: "%d:%02d ", hours, minutes) + suffix } func length(roundingToNearest interval: Double) -> String { let rounded = Int(self.rounded(to: interval)) return "\(rounded) m" } func energy(roundingToNearest interval: Double) -> String { let rounded = Int(self.rounded(to: interval)) return "\(rounded) kcal" } }