Kurdtvs-Live-Kurdish-TV-Kur.../Mastodon/Extension/Double.swift

20 lines
471 B
Swift
Raw Normal View History

2021-03-08 04:42:10 +01:00
//
// Double.swift
// Mastodon
//
// Created by sxiaojian on 2021/3/8.
//
import Foundation
extension Double {
func asString(style: DateComponentsFormatter.UnitsStyle) -> String {
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.minute, .second]
formatter.unitsStyle = style
formatter.zeroFormattingBehavior = .pad
guard let formattedString = formatter.string(from: self) else { return "" }
return formattedString
}
}