add getLastUpdatedTimeString utility function
This commit is contained in:
parent
1c95b46252
commit
cbfb3d61b0
2 changed files with 13 additions and 7 deletions
|
|
@ -252,13 +252,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
|
|
||||||
func updateRefreshControlTitle() {
|
func updateRefreshControlTitle() {
|
||||||
var atribbutedTitle = "Pull to Sync Password Store"
|
var atribbutedTitle = "Pull to Sync Password Store"
|
||||||
if let lastUpdatedTime = Defaults[.lastUpdatedTime] {
|
atribbutedTitle = "Last Sync: \(Utils.getLastUpdatedTimeString())"
|
||||||
let formatter = DateFormatter()
|
|
||||||
formatter.dateStyle = .long
|
|
||||||
formatter.timeStyle = .short
|
|
||||||
let dateString = formatter.string(from: lastUpdatedTime)
|
|
||||||
atribbutedTitle = "Last Sync: \(dateString)"
|
|
||||||
}
|
|
||||||
refreshControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
|
refreshControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import SwiftyUserDefaults
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
static func removeFileIfExists(atPath path: String) {
|
static func removeFileIfExists(atPath path: String) {
|
||||||
|
|
@ -22,4 +23,15 @@ class Utils {
|
||||||
static func removeFileIfExists(at url: URL) {
|
static func removeFileIfExists(at url: URL) {
|
||||||
removeFileIfExists(atPath: url.path)
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue