From 21fba2612d2bd18c6234826b8a53c13578cda2a8 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Tue, 9 Sep 2025 07:23:55 +0200 Subject: [PATCH] Documented the ISOTimestampTranscoder transcoder in the library target. --- .../Extensions/DateFormatter+Properties.swift | 8 +++++++- ...anscoder.swift => ISOTimestampTranscoder.swift} | 14 +++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) rename Sources/Internal/Transcoders/{ISODateTranscoder.swift => ISOTimestampTranscoder.swift} (70%) diff --git a/Sources/Internal/Extensions/DateFormatter+Properties.swift b/Sources/Internal/Extensions/DateFormatter+Properties.swift index 5a8e372..69818bf 100644 --- a/Sources/Internal/Extensions/DateFormatter+Properties.swift +++ b/Sources/Internal/Extensions/DateFormatter+Properties.swift @@ -14,7 +14,13 @@ import Foundation extension DateFormatter { - static var isoDateTime: DateFormatter { + // MARK: Properties + + /// An ISO timestamp formatter. + /// + /// This formatter implements the `yyyy-MM-dd'T'HH:mm:ss.SSSSSS` custom date format. + /// Within the context of this library, this formatter is solely used to decode a date formatted as a timestamp that is returned by the ``AmiiboService/getLastUpdated()`` function. + static var isoTimestamp: DateFormatter { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS" diff --git a/Sources/Internal/Transcoders/ISODateTranscoder.swift b/Sources/Internal/Transcoders/ISOTimestampTranscoder.swift similarity index 70% rename from Sources/Internal/Transcoders/ISODateTranscoder.swift rename to Sources/Internal/Transcoders/ISOTimestampTranscoder.swift index 6b81d5b..887cd63 100644 --- a/Sources/Internal/Transcoders/ISODateTranscoder.swift +++ b/Sources/Internal/Transcoders/ISOTimestampTranscoder.swift @@ -13,10 +13,18 @@ import Foundation import OpenAPIRuntime -struct ISODateTranscoder: DateTranscoder { - +/// 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 = .isoDateTime + + private let dateFormatter: DateFormatter = .isoTimestamp + +} + + // MARK: - DateTranscoder + +extension ISOTimestampTranscoder: DateTranscoder { // MARK: Functions