date(_:matchesComponents:)

Determine if the Date has all of the specified DateComponents.

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
func date(_ date: Date, matchesComponents components: DateComponents) -> Bool

Returns

true if the date matches all of the components, otherwise false.

It may be useful to test the return value of nextDate(after:matching:matchingPolicy:behavior:direction:) to find out if the components were obeyed or if the method had to fudge the result value due to missing time (for example, a daylight saving time transition).