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 +18
-2
lines changed
Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,25 @@ import Foundation
22
33extension NSDate {
44
5+ // TODO: Make `static let` after conversion since it's not used outside WordPressKit
6+ @objc
7+ static func rfc3339DateFormatter( ) -> DateFormatter {
8+ DateFormatter . rfc3339Formatter
9+ }
10+
511 @objc ( WordPressComJSONString)
612 public func wordPressComJSONString( ) -> String {
713 NSDate . rfc3339DateFormatter ( ) . string ( from: self as Date )
814 }
915}
16+
17+ extension DateFormatter {
18+
19+ static let rfc3339Formatter : DateFormatter = {
20+ let formatter = DateFormatter ( )
21+ formatter. dateFormat = " yyyy'-'MM'-'dd'T'HH':'mm':'ssZ "
22+ formatter. timeZone = NSTimeZone ( forSecondsFromGMT: 0 ) as TimeZone
23+ formatter. locale = NSLocale ( localeIdentifier: " en_US_POSIX " ) as Locale
24+ return formatter
25+ } ( )
26+ }
Original file line number Diff line number Diff line change 22
33@interface NSDate (WordPressJSON)
44
5- + (NSDateFormatter *)rfc3339DateFormatter ;
6-
75/* *
86 Parses a date string
97
Original file line number Diff line number Diff line change 22
33@implementation NSDate (WordPressJSON)
44
5+ // FIXME: This is here only for the benefit of dateWithWordPressComJSONString. Remove together with that.
56+ (NSDateFormatter *)rfc3339DateFormatter {
67 static NSDateFormatter *rfc3339DateFormatter;
78 if (rfc3339DateFormatter == nil ) {
You can’t perform that action at this time.
0 commit comments