Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 5686c93

Browse files
committed
Restore rfc3339DateFormatter() method for backwards compatibility
1 parent b0ed585 commit 5686c93

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

WordPressKit/NSDate+RFC3339.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import Foundation
22

33
extension NSDate {
44

5+
static let rfc3339Formatter = DateFormatter.rfc3339Formatter
6+
57
@objc
6-
static let rfc3339DateFormatter = DateFormatter.rfc3339Formatter
8+
@available(*, deprecated, message: "Please use the static property instead. This is here for backwards compatibility and will soon be removed.")
9+
public static func rfc3339DateFormatter() -> DateFormatter {
10+
rfc3339Formatter
11+
}
712

813
/// Parses a date string
914
///
@@ -17,12 +22,12 @@ extension NSDate {
1722
// Needs to be `public` because of the usages in the Objective-C code.
1823
@objc(dateWithWordPressComJSONString:)
1924
public static func with(wordPressComJSONString jsonString: String) -> Date? {
20-
self.rfc3339DateFormatter.date(from: jsonString)
25+
self.rfc3339Formatter.date(from: jsonString)
2126
}
2227

2328
@objc(WordPressComJSONString)
2429
public func wordPressComJSONString() -> String {
25-
NSDate.rfc3339DateFormatter.string(from: self as Date)
30+
NSDate.rfc3339Formatter.string(from: self as Date)
2631
}
2732
}
2833

WordPressKit/PostServiceRemoteREST+Extended.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private func decodePost(from object: AnyObject) async throws -> RemotePost {
4040

4141
private 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.rfc3339Formatter)
4444
let data = try encoder.encode(value)
4545
let object = try JSONSerialization.jsonObject(with: data)
4646
guard let dictionary = object as? [String: AnyObject] else {

WordPressKitTests/NSDate+RFC3339Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import XCTest
1010
class NSDateRFC3339Tests: XCTestCase {
1111

1212
func testDateFormatterConfiguration() throws {
13-
let rfc3339Formatter = try XCTUnwrap(NSDate.rfc3339DateFormatter)
13+
let rfc3339Formatter = try XCTUnwrap(NSDate.rfc3339Formatter)
1414

1515
XCTAssertEqual(rfc3339Formatter.timeZone, TimeZone(secondsFromGMT: 0))
1616
XCTAssertEqual(rfc3339Formatter.locale, Locale(identifier: "en_US_POSIX"))

0 commit comments

Comments
 (0)