mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-08-03 12:37:15 -04:00
Use a single instance of date formatter
This commit is contained in:
parent
c8aa5f5275
commit
703e6e34eb
@ -16,14 +16,18 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
|
||||
/// Format the current date the way as it would come from a server's Last-Modified header
|
||||
/// - Returns: eg: Thu, 16 May 2024 11:38:20 GMT
|
||||
func formatAsGMT() -> String {
|
||||
|
||||
private static let dateFormatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss 'GMT'"
|
||||
formatter.locale = Locale(identifier: "en_US")
|
||||
formatter.timeZone = TimeZone(abbreviation: "GMT")
|
||||
return formatter.string(from: self)
|
||||
return formatter
|
||||
}()
|
||||
|
||||
/// Format the current date the way as it would come from a server's Last-Modified header
|
||||
/// - Returns: eg: Thu, 16 May 2024 11:38:20 GMT
|
||||
func formatAsGMT() -> String {
|
||||
Self.dateFormatter.string(from: self)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user