Created
August 29, 2019 06:49
-
-
Save DineshKachhot/3a741b8879fee7d1b53e37528e2afd23 to your computer and use it in GitHub Desktop.
Audio/Video Duration formate in Swift 4.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension TimeInterval { | |
struct DateComponents { | |
static let formatterPositional: DateComponentsFormatter = { | |
let formatter = DateComponentsFormatter() | |
formatter.allowedUnits = [.hour,.minute,.second] | |
formatter.unitsStyle = .positional | |
formatter.zeroFormattingBehavior = .pad | |
return formatter | |
}() | |
} | |
var positionalTime: String { | |
return DateComponents.formatterPositional.string(from: self) ?? "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment