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-10-25 20:20:41 +01:00
|
|
|
/// An ISO date formatter for the `yyyy-MM-dd` format.
|
2026-03-27 17:14:26 +00:00
|
|
|
static let isoDate: DateFormatter = {
|
|
|
|
|
let formatter = DateFormatter()
|
|
|
|
|
|
2026-10-25 20:20:41 +01:00
|
|
|
// The POSIX locale keeps the user's locale and 12/24-hour setting from altering fixed-format parsing.
|
2026-07-26 09:56:32 +00:00
|
|
|
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
|
|
|
|
|
}()
|
|
|
|
|
|
2026-10-25 20:20:41 +01:00
|
|
|
/// An ISO timestamp formatter for the `yyyy-MM-dd'T'HH:mm:ss.SSSSSS` format.
|
2025-09-09 17:30:19 +00:00
|
|
|
///
|
2026-10-25 20:20:41 +01:00
|
|
|
/// Used only to decode the timestamp returned by ``AmiiboService/getLastUpdated()``.
|
2026-03-27 17:14:26 +00:00
|
|
|
static let isoTimestamp: DateFormatter = {
|
2024-09-14 22:26:39 +00:00
|
|
|
let formatter = DateFormatter()
|
|
|
|
|
|
2026-10-25 20:20:41 +01:00
|
|
|
// The POSIX locale keeps the user's locale and 12/24-hour setting from altering fixed-format parsing.
|
2026-07-26 09:56:32 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
}
|