Files
amiibo-service/Tests/AmiiboService/Helpers/Extensions/Date+UTC.swift
T

45 lines
1.1 KiB
Swift

// ===----------------------------------------------------------------------===
//
// This source file is part of the Amiibo Service open source project
//
// Copyright (c) 2026 Röck+Cöde VoF. and the Amiibo Service project authors
// Licensed under Apache license v2.0
//
// See LICENSE for license information
// See CONTRIBUTORS for the list of Amiibo Service project authors
//
// SPDX-License-Identifier: Apache-2.0
//
// ===----------------------------------------------------------------------===
import Foundation
extension Date {
// MARK: Functions
/// Makes a date from UTC components.
static func utc(
_ year: Int,
_ month: Int,
_ day: Int,
_ hour: Int = 0,
_ minute: Int = 0,
_ second: Int = 0
) -> Date {
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = .init(secondsFromGMT: 0)!
return calendar.date(from: .init(
year: year,
month: month,
day: day,
hour: hour,
minute: minute,
second: second
))!
}
}