2025-10-07 22:32:54 +00:00
// ===----------------------------------------------------------------------===
//
// This source file is part of the Amiibo Service open source project
//
2026-03-22 23:39:48 +00:00
// Copyright (c) 2026 Röck+Cöde VoF. and the Amiibo Service project authors
2025-10-07 22:32:54 +00:00
// Licensed under Apache license v2.0
//
2024-09-14 22:26:39 +00:00
// See LICENSE for license information
2025-10-07 22:32:54 +00:00
// See CONTRIBUTORS for the list of Amiibo Service project authors
2024-09-14 22:26:39 +00:00
//
2025-10-07 22:32:54 +00:00
// SPDX-License-Identifier: Apache-2.0
//
// ===----------------------------------------------------------------------===
2024-09-14 22:26:39 +00:00
import Foundation
extension DateFormatter {
2025-09-09 17:30:19 +00:00
// MARK: Properties
2026-03-27 17:14:26 +00:00
/// An ISO date formatter.
///
/// This formatter implements the `yyyy-MM-dd` date format.
static let isoDate : DateFormatter = {
let formatter = DateFormatter ()
2026-07-26 01:24:13 +02:00
// A fixed-format date requires the POSIX locale, as the user's locale or 12/24-hour setting could otherwise alter the parsing.
formatter . locale = . init ( identifier : "en_US_POSIX" )
2026-03-27 17:14:26 +00:00
formatter . dateFormat = "yyyy-MM-dd"
formatter . timeZone = . init ( secondsFromGMT : 0 )
return formatter
}()
2025-09-09 17:30:19 +00:00
/// 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.
2026-03-27 17:14:26 +00:00
static let isoTimestamp : DateFormatter = {
2024-09-14 22:26:39 +00:00
let formatter = DateFormatter ()
2026-07-26 01:24:13 +02:00
// A fixed-format date requires the POSIX locale, as the user's locale or 12/24-hour setting could otherwise alter the parsing.
formatter . locale = . init ( identifier : "en_US_POSIX" )
2024-09-14 22:26:39 +00:00
formatter . dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS"
formatter . timeZone = . init ( secondsFromGMT : 0 )
return formatter
2026-03-27 17:14:26 +00:00
}()
2024-09-14 22:26:39 +00:00
}