diff --git a/Model/Utilities/Date+Extension.swift b/Model/Utilities/Date+Extension.swift index 3b45c90b..7cf54f2c 100644 --- a/Model/Utilities/Date+Extension.swift +++ b/Model/Utilities/Date+Extension.swift @@ -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) } }