Browse Source

Merge branch 'master' of https://git.yishihui.com/iOS/BFCommonKit into media

wenweiwei 3 years ago
parent
commit
dcb216cf1a

+ 1 - 60
BFCommonKit/Classes/BFCategorys/BFNumber+Ext.swift

@@ -46,66 +46,7 @@ public extension Int {
     }
 }
 
-// MARK: - Float64 double类型扩展
-
-/// Float64 double类型扩展
-
-public extension Float64 {
-    /// 时长转化为分秒 62'52"
-    /// - Returns: <#description#>
-    func formatDurationToMS() -> String {
-        let duration = lround(self)
-        var text = ""
-        let min = duration / 60
-        let second = duration % 60
-        if min > 0, second > 0 {
-            text = "\(min)" + "\'" + "\(second)" + "\""
-        } else if min > 0 {
-            text = "\(min)" + "\'" + "0\""
-        } else {
-            text = "\(second)" + "\""
-        }
-        return text
-    }
-
-    /// 时长转化成时分秒 01:02:52
-    /// - Parameter value: <#value description#>
-    /// - Returns: <#description#>
-    func formatDurationToHMS() -> String {
-        var theTime = lround(self)
-        var theTime1 = 0 // 分
-        var theTime2 = 0 // 小时
-        if theTime < 60 {
-            if theTime < 10 {
-                return "00:0\(theTime)"
-            }
-            return "00:\(theTime)"
-        }
-        theTime1 = theTime / 60
-        theTime = theTime % 60
-        if theTime1 > 60 {
-            theTime2 = theTime1 / 60
-            theTime1 = theTime1 % 60
-        }
-        var result = "\(theTime)"
-        if theTime < 10 {
-            result = "0" + result
-        }
-        if theTime1 > 0 {
-            result = "\(theTime1):" + result
-            if theTime1 < 10 {
-                result = "0" + result
-            }
-        }
-        if theTime2 > 0 {
-            result = "\(theTime2):" + result
-            if theTime2 < 10 {
-                result = "0" + result
-            }
-        }
-        return result
-    }
-}
+// MARK: - Float double类型扩展
 
 extension Float {
     /// 准确的小数尾截取 - 没有进位

+ 66 - 0
BFCommonKit/Classes/BFCategorys/Date+Ext.swift

@@ -0,0 +1,66 @@
+//
+//  Date+Ext.swift
+//  BFCommonKit
+//
+//  Created by 胡志强 on 2021/12/10.
+//
+
+import Foundation
+
+//MARK: 转换为时间格式
+public extension Double {
+    /// 时长转化为分秒 62'52"
+    /// - Returns: <#description#>
+    func formatDurationToMS() -> String {
+        let duration = lround(self)
+        var text = ""
+        let min = duration / 60
+        let second = duration % 60
+        if min > 0, second > 0 {
+            text = "\(min)" + "\'" + "\(second)" + "\""
+        } else if min > 0 {
+            text = "\(min)" + "\'" + "0\""
+        } else {
+            text = "\(second)" + "\""
+        }
+        return text
+    }
+
+    /// 时长转化成时分秒 01:02:52
+    /// - Parameter value: <#value description#>
+    /// - Returns: <#description#>
+    func formatDurationToHMS() -> String {
+        var theTime = lround(self)
+        var theTime1 = 0 // 分
+        var theTime2 = 0 // 小时
+        if theTime < 60 {
+            if theTime < 10 {
+                return "00:0\(theTime)"
+            }
+            return "00:\(theTime)"
+        }
+        theTime1 = theTime / 60
+        theTime = theTime % 60
+        if theTime1 > 60 {
+            theTime2 = theTime1 / 60
+            theTime1 = theTime1 % 60
+        }
+        var result = "\(theTime)"
+        if theTime < 10 {
+            result = "0" + result
+        }
+        if theTime1 > 0 {
+            result = "\(theTime1):" + result
+            if theTime1 < 10 {
+                result = "0" + result
+            }
+        }
+        if theTime2 > 0 {
+            result = "\(theTime2):" + result
+            if theTime2 < 10 {
+                result = "0" + result
+            }
+        }
+        return result
+    }
+}