<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCalendar/range(of:start:interval:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCalendar(im)rangeOfUnit:startDate:interval:forDate:"
  },
  "title" : "range(of:start:interval:for:)"
}
-->

# range(of:start:interval:for:)

Returns by reference the starting time and duration of a given calendar unit that contains a given date.

```
func range(of unit: NSCalendar.Unit, start datep: AutoreleasingUnsafeMutablePointer<NSDate?>?, interval tip: UnsafeMutablePointer<TimeInterval>?, for date: Date) -> Bool
```

## Parameters

`unit`

A calendar unit (see [`NSCalendar.Unit`](/documentation/Foundation/NSCalendar/Unit) for possible values).

`datep`

Upon return, contains the starting time of the calendar unit `unit` that contains the date `date`

`tip`

Upon return, contains the duration of the calendar unit `unit` that contains the date `date`

`date`

A date.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the starting time and duration of a unit could be calculated, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)