dateInterval(of:for:)
Returns the starting time and duration of a given calendar component that contains a given date.
Declaration
func dateInterval(of component: Calendar.Component, for date: Date) -> DateInterval?Parameters
- component:
A calendar component.
- date:
The specified date.
Return Value
A new DateInterval if the starting time and duration of a component could be calculated; otherwise, nil.