Skip to content

Commit

Permalink
Remove URLEncoded DateDecodingStrategy.formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Dec 24, 2024
1 parent 951e947 commit 15e32b0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public struct URLEncodedFormDecoder: Sendable {
/// Decode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
case iso8601

/// Decode the `Date` as a string parsed by the given formatter.
case formatted(DateFormatter)

/// Decode the `Date` as a custom value encoded by the given closure.
case custom(@Sendable (_ decoder: Decoder) throws -> Date)
}
Expand Down Expand Up @@ -632,12 +629,6 @@ extension _URLEncodedFormDecoder {
}
#endif
return date
case .formatted(let formatter):
let dateString = try unbox(node, as: String.self)
guard let date = formatter.date(from: dateString) else {
throw DecodingError.dataCorrupted(.init(codingPath: self.codingPath, debugDescription: "Invalid date format"))
}
return date
case .custom(let closure):
self.storage.push(container: node)
defer { self.storage.popContainer() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public struct URLEncodedFormEncoder: Sendable {
/// Encode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
case iso8601

/// Encode the `Date` as a string parsed by the given formatter.
case formatted(DateFormatter)

/// Encode the `Date` as a custom value encoded by the given closure.
case custom(@Sendable (Date, Encoder) throws -> Void)
}
Expand Down Expand Up @@ -335,8 +332,6 @@ extension _URLEncodedFormEncoder {
#else
try self.encode(URLEncodedForm.iso8601Formatter.string(from: date))
#endif
case .formatted(let formatter):
try self.encode(formatter.string(from: date))
case .custom(let closure):
try closure(date, self)
}
Expand Down
6 changes: 0 additions & 6 deletions Tests/HummingbirdTests/URLEncodedForm/URLDecoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,6 @@ final class URLDecodedFormDecoderTests: XCTestCase {
self.testForm(test, query: "d=980694843000", decoder: .init(dateDecodingStrategy: .millisecondsSince1970))
self.testForm(test, query: "d=980694843", decoder: .init(dateDecodingStrategy: .secondsSince1970))
self.testForm(test, query: "d=2001-01-28T15%3A14%3A03Z", decoder: .init(dateDecodingStrategy: .iso8601))

let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
self.testForm(test, query: "d=2001-01-28T15%3A14%3A03.000Z", decoder: .init(dateDecodingStrategy: .formatted(dateFormatter)))
}

func testDataBlobDecode() {
Expand Down
6 changes: 0 additions & 6 deletions Tests/HummingbirdTests/URLEncodedForm/URLEncoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,6 @@ final class URLEncodedFormEncoderTests: XCTestCase {
self.testForm(test, query: "d=980694843000.0", encoder: .init(dateEncodingStrategy: .millisecondsSince1970))
self.testForm(test, query: "d=980694843.0", encoder: .init(dateEncodingStrategy: .secondsSince1970))
self.testForm(test, query: "d=2001-01-28T15:14:03Z", encoder: .init(dateEncodingStrategy: .iso8601))

let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
self.testForm(test, query: "d=2001-01-28T15:14:03.000Z", encoder: .init(dateEncodingStrategy: .formatted(dateFormatter)))
}

func testDataBlobEncode() {
Expand Down

0 comments on commit 15e32b0

Please sign in to comment.