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

19 lines
474 B
Swift
Raw Permalink Normal View History

2021-04-07 19:15:22 +00:00
//
// 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)
}
}