Documented the ISOTimestampTranscoder transcoder in the library target.

This commit is contained in:
2025-09-09 07:23:55 +02:00
parent 06ea92b72e
commit 21fba2612d
2 changed files with 18 additions and 4 deletions
@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===
//
// 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
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()
}
}