<!--
{
  "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" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFCalendarGetTimeRangeOfUnit(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFCalendarGetTimeRangeOfUnit"
  },
  "title" : "CFCalendarGetTimeRangeOfUnit(_:_:_:_:_:)"
}
-->

# CFCalendarGetTimeRangeOfUnit(_:_:_:_:_:)

Returns by reference the start time and duration of a given calendar unit that contains a given absolute time.

```
func CFCalendarGetTimeRangeOfUnit(_ calendar: CFCalendar!, _ unit: CFCalendarUnit, _ at: CFAbsoluteTime, _ startp: UnsafeMutablePointer<CFAbsoluteTime>!, _ tip: UnsafeMutablePointer<CFTimeInterval>!) -> Bool
```

## Parameters

`calendar`

The calendar to examine.

`unit`

A calendar unit (for valid values, see [`CFCalendarUnit`](/documentation/CoreFoundation/CFCalendarUnit)).

`at`

An absolute time.

`startp`

Upon return, contains the beginning of the calendar unit specified by `unit` that contains the time `at`.

`tip`

Upon return, contains the duration of the calendar unit specified by `unit` that contains the time `at`.

## Return Value

`true` if the values of `startp` and `tip` could be calculated, otherwise `false`.

## Discussion

The function may fail if, for example, you try to get the range of a `kCFCalendarUnitWeekday` and specify a time (`at`) that is during a weekend.

---

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)