You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
723 B
30 lines
723 B
//
|
|
// Utility.swift
|
|
// AVPlayer-SwiftUI
|
|
//
|
|
// Created by Chris Mash on 11/09/2019.
|
|
// Copyright © 2019 Chris Mash. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class Utility: NSObject {
|
|
|
|
private static var timeHMSFormatter: DateComponentsFormatter = {
|
|
let formatter = DateComponentsFormatter()
|
|
formatter.unitsStyle = .positional
|
|
formatter.allowedUnits = [.minute, .second]
|
|
formatter.zeroFormattingBehavior = [.pad]
|
|
return formatter
|
|
}()
|
|
|
|
static func formatSecondsToHMS(_ seconds: Double) -> String {
|
|
guard !seconds.isNaN,
|
|
let text = timeHMSFormatter.string(from: seconds) else {
|
|
return "00:00"
|
|
}
|
|
|
|
return text
|
|
}
|
|
|
|
}
|