Skip to content

Instance Method

date(_:matchesComponents:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Determines if the date has all of the specified date components.
func date(_ date: Date, matchesComponents components: DateComponents) -> Bool

Return Value

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

Discussion

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).