forked from zelo72/mastodon-ios
20 lines
471 B
Swift
20 lines
471 B
Swift
|
//
|
||
|
// 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
|
||
|
}
|
||
|
}
|