Screaming-Reminder/Screaming Reminder/Models/Extensions.swift
2024-07-30 14:42:42 +02:00

34 lines
843 B
Swift

//
// Extensions.swift
// Screaming Reminder
//
// Created by Amine Bou on 23/07/2024.
//
import Foundation
extension Date {
func withSpecificHour(hour: Int) -> Date {
var dateComponents = Calendar.current.dateComponents(in: TimeZone.current, from: self)
dateComponents.hour = hour
dateComponents.minute = 0
return Calendar.current.date(from: dateComponents).unsafelyUnwrapped
}
func atZeroMinutes() -> Date {
var dateComponents = Calendar.current.dateComponents(in: TimeZone.current, from: self)
dateComponents.minute = 0
return Calendar.current.date(from: dateComponents).unsafelyUnwrapped
}
}
extension Set {
mutating func insertAll(_ newMembers: [Set.Element]) {
newMembers.forEach { (member) in
self.insert(member)
}
}
}