---
title: "ordinality(of:in:for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/calendar/ordinality(of:in:for:)"
---

# ordinality(of:in:for:)

Returns, for a given absolute time, the ordinal number of a smaller calendar component (such as a day) within a specified larger calendar component (such as a week).

## Declaration

```swift
func ordinality(of smaller: Calendar.Component, in larger: Calendar.Component, for date: Date) -> Int?
```

## Parameters

- `smaller`: The smaller calendar component.
- `larger`: The larger calendar component.
- `date`: The absolute time for which the calculation is performed.

## Return Value

Return Value The ordinal number of smaller within larger at the time specified by date. Returns nil if larger is not logically bigger than smaller in the calendar, or the given combination of components does not make sense (or is a computation which is undefined).

## Discussion

Discussion The ordinality is in most cases not the same as the decomposed value of the component. Typically return values are 1 and greater. For example, the time 00:45 is in the first hour of the day, and for components hour and day respectively, the result would be 1. An exception is the week-in-month calculation, which returns 0 for days before the first week in the month containing the date. note: Some computations can take a relatively long time.

## See Also

### Getting Calendar Information

- [identifier](foundation/calendar/identifier-swift.property.md)
- [locale](foundation/calendar/locale.md)
- [firstWeekday](foundation/calendar/firstweekday.md)
- [minimumDaysInFirstWeek](foundation/calendar/minimumdaysinfirstweek.md)
- [timeZone](foundation/calendar/timezone.md)
- [maximumRange(of:)](foundation/calendar/maximumrange(of:).md)
- [minimumRange(of:)](foundation/calendar/minimumrange(of:).md)
- [range(of:in:for:)](foundation/calendar/range(of:in:for:).md)
