Display last updated date in absolut instead of relative form
This is necessary to have a language independent representation. For example, the previous format would have produced a grammatically wrong term in German.
This commit is contained in:
parent
116e258d05
commit
3cf55d91ff
2 changed files with 10 additions and 13 deletions
|
|
@ -154,7 +154,6 @@
|
||||||
// Time related
|
// Time related
|
||||||
"Unknown" = "Unknown";
|
"Unknown" = "Unknown";
|
||||||
"JustNow" = "Just now";
|
"JustNow" = "Just now";
|
||||||
"TimeAgo" = "%@ ago";
|
|
||||||
|
|
||||||
// Commit messages
|
// Commit messages
|
||||||
"AddPassword." = "Add password for %@ to store using Pass for iOS.";
|
"AddPassword." = "Add password for %@ to store using Pass for iOS.";
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,13 @@ import KeychainAccess
|
||||||
|
|
||||||
public class PasswordStore {
|
public class PasswordStore {
|
||||||
public static let shared = PasswordStore()
|
public static let shared = PasswordStore()
|
||||||
|
private static let dateFormatter: DateFormatter = {
|
||||||
|
let dateFormatter = DateFormatter()
|
||||||
|
dateFormatter.dateStyle = .short
|
||||||
|
dateFormatter.timeStyle = .short
|
||||||
|
return dateFormatter
|
||||||
|
}()
|
||||||
|
|
||||||
public let storeURL = URL(fileURLWithPath: "\(Globals.repositoryPath)")
|
public let storeURL = URL(fileURLWithPath: "\(Globals.repositoryPath)")
|
||||||
public let tempStoreURL = URL(fileURLWithPath: "\(Globals.repositoryPath)-temp")
|
public let tempStoreURL = URL(fileURLWithPath: "\(Globals.repositoryPath)-temp")
|
||||||
|
|
||||||
|
|
@ -499,19 +506,10 @@ public class PasswordStore {
|
||||||
return "Unknown".localize()
|
return "Unknown".localize()
|
||||||
}
|
}
|
||||||
let lastCommitDate = Date(timeIntervalSince1970: latestCommitTime)
|
let lastCommitDate = Date(timeIntervalSince1970: latestCommitTime)
|
||||||
let currentDate = Date()
|
if Date().timeIntervalSince(lastCommitDate) <= 60 {
|
||||||
var autoFormattedDifference: String
|
return "JustNow".localize()
|
||||||
if currentDate.timeIntervalSince(lastCommitDate) <= 60 {
|
|
||||||
autoFormattedDifference = "JustNow".localize()
|
|
||||||
} else {
|
|
||||||
let diffDate = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: lastCommitDate, to: currentDate)
|
|
||||||
let dateComponentsFormatter = DateComponentsFormatter()
|
|
||||||
dateComponentsFormatter.unitsStyle = .full
|
|
||||||
dateComponentsFormatter.maximumUnitCount = 2
|
|
||||||
dateComponentsFormatter.includesApproximationPhrase = true
|
|
||||||
autoFormattedDifference = "TimeAgo".localize(dateComponentsFormatter.string(from: diffDate)!)
|
|
||||||
}
|
}
|
||||||
return autoFormattedDifference
|
return PasswordStore.dateFormatter.string(from: lastCommitDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateRemoteRepo() {
|
public func updateRemoteRepo() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue