<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFCalendarGetOrdinalityOfUnit(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFCalendarGetOrdinalityOfUnit"
  },
  "title" : "CFCalendarGetOrdinalityOfUnit(_:_:_:_:)"
}
-->

# CFCalendarGetOrdinalityOfUnit(_:_:_:_:)

Returns the ordinal number of a calendrical unit within a larger unit at a specified absolute time.

```
func CFCalendarGetOrdinalityOfUnit(_ calendar: CFCalendar!, _ smallerUnit: CFCalendarUnit, _ biggerUnit: CFCalendarUnit, _ at: CFAbsoluteTime) -> CFIndex
```

## Parameters

`calendar`

The calendar to examine.

`smallerUnit`

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

`biggerUnit`

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

`at`

An absolute time.

## Return Value

The ordinal number of the calendar unit specified by `smallerUnit` within the calendar unit specified by `biggerUnit` at the absolute time `at`. For example, the time 00:45 is in the first hour of the day, and for units Hour and Day respectively, the result would be 1.

## Discussion

If the `biggerUnit` parameter is not logically bigger than the `smallerUnit` parameter in the calendar, or the given combination of units does not make sense (or is a computation which is undefined), the result is `kCFNotFound`.

## Discussion

The ordinality is in most cases not the same as the decomposed value of the unit. Typically return values are `1` and greater; an exception is the week-in-month calculation, which returns `0` for days before the first week in the month containing the date. Note that some computations can take a relatively long time to perform.

---

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)