---
title: "date(_:matchesComponents:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/calendar/date(_:matchescomponents:)"
---

# date(_:matchesComponents:)

Determines if the date has all of the specified date components.

## Declaration

```swift
func date(_ date: Date, matchesComponents components: DateComponents) -> Bool
```

## Return Value

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

## Discussion

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

## See Also

### Extracting Components

- [component(_:from:)](foundation/calendar/component(_:from:).md)
- [dateComponents(_:from:)](foundation/calendar/datecomponents(_:from:).md)
- [dateComponents(_:from:to:)](foundation/calendar/datecomponents(_:from:to:)-2kcg.md)
- [dateComponents(_:from:to:)](foundation/calendar/datecomponents(_:from:to:)-5g20t.md)
- [dateComponents(in:from:)](foundation/calendar/datecomponents(in:from:).md)
- [Calendar.Component](foundation/calendar/component.md)
