From 00fb8eb175d937fdadb26f5e95090425c29bfcca Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 27 Jan 2021 19:24:31 +0800 Subject: [PATCH] fix: set header date formatter options --- .../MastodonSDK/API/Mastodon+API+Timeline.swift | 6 ------ .../Sources/MastodonSDK/API/Mastodon+API.swift | 6 +++++- .../MastodonSDK/Entity/Mastodon+Entity+Toot.swift | 2 +- .../Sources/MastodonSDK/Extension/Bool.swift | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 MastodonSDK/Sources/MastodonSDK/Extension/Bool.swift diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Timeline.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Timeline.swift index eb9271b02..13d0dc141 100644 --- a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Timeline.swift +++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Timeline.swift @@ -91,9 +91,3 @@ extension Mastodon.API.Timeline { } } } - -extension Bool { - var queryItemValue: String { - return self ? "true" : "false" - } -} diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift index f86e1fc71..8dfc1709c 100644 --- a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift +++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift @@ -11,7 +11,11 @@ import enum NIOHTTP1.HTTPResponseStatus extension Mastodon.API { static let timeoutInterval: TimeInterval = 10 - static let httpHeaderDateFormatter = ISO8601DateFormatter() + static let httpHeaderDateFormatter: ISO8601DateFormatter = { + var formatter = ISO8601DateFormatter() + formatter.formatOptions.insert(.withFractionalSeconds) + return formatter + }() static let encoder: JSONEncoder = { let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Toot.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Toot.swift index 3bf52991f..2adc9a123 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Toot.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Toot.swift @@ -18,7 +18,7 @@ extension Mastodon.Entity { public let content: String public let account: User - public let language: String + public let language: String? public let visibility: String enum CodingKeys: String, CodingKey { diff --git a/MastodonSDK/Sources/MastodonSDK/Extension/Bool.swift b/MastodonSDK/Sources/MastodonSDK/Extension/Bool.swift new file mode 100644 index 000000000..7641f6d9e --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Extension/Bool.swift @@ -0,0 +1,14 @@ +// +// Bool.swift +// +// +// Created by MainasuK Cirno on 2021/1/27. +// + +import Foundation + +extension Bool { + var queryItemValue: String { + return self ? "true" : "false" + } +}