add getLastUpdatedTimeString utility function

This commit is contained in:
Bob Sun 2017-02-09 22:12:25 +08:00
parent 1c95b46252
commit cbfb3d61b0
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 13 additions and 7 deletions

View file

@ -7,6 +7,7 @@
//
import Foundation
import SwiftyUserDefaults
class Utils {
static func removeFileIfExists(atPath path: String) {
@ -22,4 +23,15 @@ class Utils {
static func removeFileIfExists(at url: URL) {
removeFileIfExists(atPath: url.path)
}
static func getLastUpdatedTimeString() -> String {
var lastUpdatedTimeString = ""
if let lastUpdatedTime = Defaults[.lastUpdatedTime] {
let formatter = DateFormatter()
formatter.dateStyle = .long
formatter.timeStyle = .short
lastUpdatedTimeString = formatter.string(from: lastUpdatedTime)
}
return lastUpdatedTimeString
}
}