From 4d9d0a79556af4757295ce913b924d3a8486780b Mon Sep 17 00:00:00 2001 From: gregorFeigel <72912784+gregorFeigel@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:27:56 +0100 Subject: [PATCH] dateDecodingStrategy added as described in Issue #184 (#185) * dateDecodingStrategy added as described in https://github.com/nerdishbynature/octokit.swift/issues/184#issuecomment-1958792645 * dateDecodingStrategy added as described in Issue #184. --- OctoKit/Issue.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 561a8a0e..ffb4dfe3 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -331,7 +331,9 @@ public extension Octokit { state: Openness? = nil, completion: @escaping (_ response: Result) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) - return router.post(session, expectedResultType: Issue.self) { issue, error in + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return router.post(session, decoder: decoder, expectedResultType: Issue.self) { issue, error in if let error = error { completion(.failure(error)) } else { @@ -362,7 +364,9 @@ public extension Octokit { assignee: String? = nil, state: Openness? = nil) async throws -> Issue { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) - return try await router.post(session, expectedResultType: Issue.self) + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return try await router.post(session, decoder: decoder, expectedResultType: Issue.self) } #endif