0af0e3056d
This PR contains the work done to: * Documented the public properties, initializers, and/or functions of those types conforming to the `APIClient`, `KeyNameFilter`, and `KeyNameModel` protocols, to fix the issue that the protocol documentations cannot be inherited; * Moved the `AmiiboService` DocC documentation catalog inside the library target; * Amended the folder structure of the library and test targets; * Fixed further documentation issues encountered while revising the written documentation; * Added the `lib-test` task in the `Makefile` file; * Improved the naming for the existing tasks in the `Makefile` file. Reviewed-on: #8 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
41 lines
1.1 KiB
Swift
41 lines
1.1 KiB
Swift
//===----------------------------------------------------------------------===
|
|
//
|
|
// This source file is part of the AmiiboService open source project
|
|
//
|
|
// Copyright (c) 2024-2025 Röck+Cöde VoF. and the AmiiboAPI project authors
|
|
// Licensed under the EUPL 1.2 or later.
|
|
//
|
|
// See LICENSE for license information
|
|
// See CONTRIBUTORS for the list of AmiiboAPI project authors
|
|
//
|
|
//===----------------------------------------------------------------------===
|
|
|
|
import Foundation
|
|
import OpenAPIRuntime
|
|
|
|
/// A type that allows the decoding and encoding of ISO timestamp dates, defined by the `yyyy-MM-dd'T'HH:mm:ss.SSSSSS` custom date format.
|
|
struct ISOTimestampTranscoder {
|
|
|
|
// MARK: Properties
|
|
|
|
/// A formatter to use to decode and encode ISO timestamps dates.
|
|
private let dateFormatter: DateFormatter = .isoTimestamp
|
|
|
|
}
|
|
|
|
// MARK: - DateTranscoder
|
|
|
|
extension ISOTimestampTranscoder: DateTranscoder {
|
|
|
|
// MARK: Functions
|
|
|
|
func encode(_ date: Date) throws -> String {
|
|
dateFormatter.string(from: date)
|
|
}
|
|
|
|
func decode(_ string: String) throws -> Date {
|
|
dateFormatter.date(from: string) ?? .init()
|
|
}
|
|
|
|
}
|