33 lines
785 B
Swift
33 lines
785 B
Swift
//
|
|
// IntExtension.swift
|
|
// yozm
|
|
//
|
|
// Created by klaus on 2022/06/21.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension Int64 {
|
|
func durationText() -> String {
|
|
let duration = self
|
|
|
|
let convertedTime = Int(duration / 1000)
|
|
let hour = Int(convertedTime / 3600)
|
|
let minute = Int(convertedTime / 60) % 60
|
|
let second = Int(convertedTime % 60)
|
|
|
|
// update UI
|
|
var timeText = [String]()
|
|
|
|
if hour > 0 {
|
|
timeText.append(String(hour))
|
|
timeText.append(String(format: "%02d", minute))
|
|
} else {
|
|
timeText.append(String(format: "%02d", minute))
|
|
timeText.append(String(format: "%02d", second))
|
|
}
|
|
|
|
return timeText.joined(separator: ":")
|
|
}
|
|
}
|