DHBW-Service-App/DHBW-Service/Utility/DateExtension.swift

19 lines
474 B
Swift

//
// DateExtension.swift
// DHBW-Service
//
// Created by Patrick Müller on 07.04.21.
//
import Foundation
extension Date {
func get(_ components: Calendar.Component..., calendar: Calendar = Calendar.current) -> DateComponents {
return calendar.dateComponents(Set(components), from: self)
}
func get(_ component: Calendar.Component, calendar: Calendar = Calendar.current) -> Int {
return calendar.component(component, from: self)
}
}