This repository was archived by the owner on Sep 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +5
-8
lines changed
Expand file tree Collapse file tree 3 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,8 @@ import Foundation
22
33extension NSDate {
44
5- // TODO: Make `static let` after conversion since it's not used outside WordPressKit
65 @objc
7- static func rfc3339DateFormatter( ) -> DateFormatter {
8- DateFormatter . rfc3339Formatter
9- }
6+ static let rfc3339DateFormatter = DateFormatter . rfc3339Formatter
107
118 /// Parses a date string
129 ///
@@ -20,12 +17,12 @@ extension NSDate {
2017 // Needs to be `public` because of the usages in the Objective-C code.
2118 @objc ( dateWithWordPressComJSONString: )
2219 public static func with( wordPressComJSONString jsonString: String ) -> Date ? {
23- self . rfc3339DateFormatter ( ) . date ( from: jsonString)
20+ self . rfc3339DateFormatter. date ( from: jsonString)
2421 }
2522
2623 @objc ( WordPressComJSONString)
2724 public func wordPressComJSONString( ) -> String {
28- NSDate . rfc3339DateFormatter ( ) . string ( from: self as Date )
25+ NSDate . rfc3339DateFormatter. string ( from: self as Date )
2926 }
3027}
3128
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ private func decodePost(from object: AnyObject) async throws -> RemotePost {
4040
4141private func makeParameters< T: Encodable > ( from value: T ) throws -> [ String : AnyObject ] {
4242 let encoder = JSONEncoder ( )
43- encoder. dateEncodingStrategy = . formatted( NSDate . rfc3339DateFormatter ( ) )
43+ encoder. dateEncodingStrategy = . formatted( NSDate . rfc3339DateFormatter)
4444 let data = try encoder. encode ( value)
4545 let object = try JSONSerialization . jsonObject ( with: data)
4646 guard let dictionary = object as? [ String : AnyObject ] else {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import XCTest
1010class NSDateRFC3339Tests : XCTestCase {
1111
1212 func testDateFormatterConfiguration( ) throws {
13- let rfc3339Formatter = try XCTUnwrap ( NSDate . rfc3339DateFormatter ( ) )
13+ let rfc3339Formatter = try XCTUnwrap ( NSDate . rfc3339DateFormatter)
1414
1515 XCTAssertEqual ( rfc3339Formatter. timeZone, TimeZone ( secondsFromGMT: 0 ) )
1616 XCTAssertEqual ( rfc3339Formatter. locale, Locale ( identifier: " en_US_POSIX " ) )
You can’t perform that action at this time.
0 commit comments