dateInterval(of:start:interval:for:)

Returns, via two inout parameters, the starting time and duration of a given calendar component that contains a given date.

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
func dateInterval(of component: Calendar.Component, start: inout Date, interval: inout TimeInterval, for date: Date) -> Bool

Parameters

component

A calendar component.

start

Upon return, the starting time of the calendar component that contains the date.

interval

Upon return, the duration of the calendar component that contains the date.

date

The specified date.

Returns

true if the starting time and duration of a component could be calculated, otherwise false.