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