diff --git a/Sources/JellyfinClient.swift b/Sources/JellyfinClient.swift index 2661b7e32..aaa49c38f 100644 --- a/Sources/JellyfinClient.swift +++ b/Sources/JellyfinClient.swift @@ -41,7 +41,8 @@ public final class JellyfinClient { configuration.delegate = self configuration.sessionDelegate = sessionDelegate - let isoDateFormatter: DateFormatter = OpenISO8601DateFormatter() + let isoDateFormatter: DateFormatter = ISO8601DateFormatter() + isoDateFormatter.formatOptions = .withFractionalSeconds let decoder = JSONDecoder() decoder.dateDecodingStrategy = .formatted(isoDateFormatter) diff --git a/Sources/OpenISO8601Formatter.swift b/Sources/OpenISO8601Formatter.swift deleted file mode 100644 index 6e5635935..000000000 --- a/Sources/OpenISO8601Formatter.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// jellyfin-sdk-swift is subject to the terms of the Mozilla Public -// License, v2.0. If a copy of the MPL was not distributed with this -// file, you can obtain one at https://mozilla.org/MPL/2.0/. -// -// Copyright (c) 2023 Jellyfin & Jellyfin Contributors -// - -import Foundation - -// https://stackoverflow.com/a/50281094/976628 -public class OpenISO8601DateFormatter: DateFormatter { - static let withoutSeconds: DateFormatter = { - let formatter = DateFormatter() - formatter.calendar = Calendar(identifier: .iso8601) - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.timeZone = TimeZone(secondsFromGMT: 0) - formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" - return formatter - }() - - private func setup() { - calendar = Calendar(identifier: .iso8601) - locale = Locale(identifier: "en_US_POSIX") - timeZone = TimeZone(secondsFromGMT: 0) - dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" - } - - override init() { - super.init() - setup() - } - - required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - setup() - } - - override public func date(from string: String) -> Date? { - if let result = super.date(from: string) { - return result - } - return OpenISO8601DateFormatter.withoutSeconds.date(from: string) - } -}