---
title: "CFCalendarGetTimeRangeOfUnit(_:_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfcalendargettimerangeofunit(_:_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.corefoundation/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

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

## Discussion

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.

## See Also

### Getting Ranges of Units

- [CFCalendarGetRangeOfUnit(_:_:_:_:)](corefoundation/cfcalendargetrangeofunit(_:_:_:_:).md)
- [CFCalendarGetOrdinalityOfUnit(_:_:_:_:)](corefoundation/cfcalendargetordinalityofunit(_:_:_:_:).md)
- [CFCalendarGetMaximumRangeOfUnit(_:_:)](corefoundation/cfcalendargetmaximumrangeofunit(_:_:).md)
- [CFCalendarGetMinimumRangeOfUnit(_:_:)](corefoundation/cfcalendargetminimumrangeofunit(_:_:).md)
