perf: cache RelativeDateTimeFormatter; add .DS_Store to .gitignore
Co-authored-by: robonen <26167508+robonen@users.noreply.github.com>
This commit is contained in:
@@ -8,5 +8,9 @@ DerivedData/
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
# Swift Package Manager
|
||||
.build/
|
||||
.swiftpm/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
@@ -117,8 +117,12 @@ struct NotificationRowView: View {
|
||||
|
||||
extension Date {
|
||||
var relativeFormatted: String {
|
||||
Date.relativeDateTimeFormatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
|
||||
private static let relativeDateTimeFormatter: RelativeDateTimeFormatter = {
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
formatter.locale = Locale(identifier: "ru_RU")
|
||||
return formatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
return formatter
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -124,8 +124,12 @@ struct MaydayLiveActivityLiveActivity: Widget {
|
||||
|
||||
extension Date {
|
||||
var relativeFormatted: String {
|
||||
Date.relativeDateTimeFormatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
|
||||
private static let relativeDateTimeFormatter: RelativeDateTimeFormatter = {
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
formatter.locale = Locale(identifier: "ru_RU")
|
||||
return formatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
return formatter
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user