<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Calendar",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8CalendarV"
  },
  "title" : "Calendar"
}
-->

# Calendar

A definition of the relationships between calendar units and absolute points in time, providing features for calculation and comparison of dates.

```
struct Calendar
```

## Overview

`Calendar` encapsulates information about systems of reckoning time in which the beginning, length, and divisions of a year are defined. It provides information about the calendar and support for calendrical computations such as determining the range of a given calendrical unit and adding units to a given absolute time.

## Topics

### Creating a Calendar

[`Calendar.Identifier`](/documentation/Foundation/Calendar/Identifier-swift.enum)

An enumeration for the available calendars.

### Getting the User’s Calendar

[`autoupdatingCurrent`](/documentation/Foundation/Calendar/autoupdatingCurrent)

A calendar that tracks changes to user’s preferred calendar.

[`current`](/documentation/Foundation/Calendar/current)

The user’s current calendar.

### Extracting Components

[`date(_:matchesComponents:)`](/documentation/Foundation/Calendar/date(_:matchesComponents:))

Determines if the date has all of the specified date components.

[`component(_:from:)`](/documentation/Foundation/Calendar/component(_:from:))

Returns the value for one component of a date.

[`dateComponents(_:from:)`](/documentation/Foundation/Calendar/dateComponents(_:from:))

Returns all the date components of a date, using the calendar time zone.

[`dateComponents(_:from:to:)`](/documentation/Foundation/Calendar/dateComponents(_:from:to:)-2kcg)

Returns the difference between two dates.

[`dateComponents(_:from:to:)`](/documentation/Foundation/Calendar/dateComponents(_:from:to:)-5g20t)

Returns the difference between two dates specified as `DateComponents`.

[`dateComponents(in:from:)`](/documentation/Foundation/Calendar/dateComponents(in:from:))

Returns all the date components of a date, as if in a given time zone (instead of the `Calendar` time zone).

[`Calendar.Component`](/documentation/Foundation/Calendar/Component)

An enumeration for the various components of a calendar date.

### Getting Calendar Information

[`identifier`](/documentation/Foundation/Calendar/identifier-swift.property)

The identifier of the calendar.

[`locale`](/documentation/Foundation/Calendar/locale)

The locale of the calendar.

[`firstWeekday`](/documentation/Foundation/Calendar/firstWeekday)

The first day of the week for the calendar.

[`minimumDaysInFirstWeek`](/documentation/Foundation/Calendar/minimumDaysInFirstWeek)

The number of minimum days in the first week.

[`timeZone`](/documentation/Foundation/Calendar/timeZone)

The time zone of the calendar.

[`maximumRange(of:)`](/documentation/Foundation/Calendar/maximumRange(of:))

The maximum range limits of the values that a given component can take on.

[`minimumRange(of:)`](/documentation/Foundation/Calendar/minimumRange(of:))

Returns the minimum range limits of the values that a given component can take on.

[`ordinality(of:in:for:)`](/documentation/Foundation/Calendar/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).

[`range(of:in:for:)`](/documentation/Foundation/Calendar/range(of:in:for:))

Returns the range of absolute time values that a smaller calendar component (such as a day) can take on in a larger calendar component (such as a month) that includes a specified absolute time.

### Scanning Dates

[`startOfDay(for:)`](/documentation/Foundation/Calendar/startOfDay(for:))

Returns the first moment of a given Date, as a Date.

[`enumerateDates(startingAfter:matching:matchingPolicy:repeatedTimePolicy:direction:using:)`](/documentation/Foundation/Calendar/enumerateDates(startingAfter:matching:matchingPolicy:repeatedTimePolicy:direction:using:))

Computes the dates which match (or most closely match) a given set of components, and calls the closure once for each of them, until the enumeration is stopped.

[`nextDate(after:matching:matchingPolicy:repeatedTimePolicy:direction:)`](/documentation/Foundation/Calendar/nextDate(after:matching:matchingPolicy:repeatedTimePolicy:direction:))

Computes the next date which matches (or most closely matches) a given set of components.

[`Calendar.MatchingPolicy`](/documentation/Foundation/Calendar/MatchingPolicy)

A hint to the search algorithm to control the method used for searching for dates.

[`Calendar.RepeatedTimePolicy`](/documentation/Foundation/Calendar/RepeatedTimePolicy)

Determines which result to use when a time is repeated on a day in a calendar (for example, during a daylight saving transition when the times between 2:00am and 3:00am may happen twice).

### Calculating Dates from Components

[`date(from:)`](/documentation/Foundation/Calendar/date(from:))

Returns a date created from the specified components.

[`date(byAdding:to:wrappingComponents:)`](/documentation/Foundation/Calendar/date(byAdding:to:wrappingComponents:))

Returns a new `Date` representing the date calculated by adding components to a given date.

[`date(byAdding:value:to:wrappingComponents:)`](/documentation/Foundation/Calendar/date(byAdding:value:to:wrappingComponents:))

Returns a new `Date` representing the date calculated by adding an amount of a specific component to a given date.

[`date(bySetting:value:of:)`](/documentation/Foundation/Calendar/date(bySetting:value:of:))

Returns a new `Date` representing the date calculated by setting a specific component to a given time, and trying to keep lower components the same.  If the component already has that value, this may result in a date which is the same as the given date.

[`date(bySettingHour:minute:second:of:matchingPolicy:repeatedTimePolicy:direction:)`](/documentation/Foundation/Calendar/date(bySettingHour:minute:second:of:matchingPolicy:repeatedTimePolicy:direction:))

Returns a new `Date` representing the date calculated by setting hour, minute, and second to a given time on a specified `Date`.

### Calculating Intervals

[`dateInterval(of:for:)`](/documentation/Foundation/Calendar/dateInterval(of:for:))

Returns the starting time and duration of a given calendar component that contains a given date.

[`dateInterval(of:start:interval:for:)`](/documentation/Foundation/Calendar/dateInterval(of:start:interval:for:))

Returns, via two inout parameters, the starting time and duration of a given calendar component that contains a given date.

[`dateIntervalOfWeekend(containing:)`](/documentation/Foundation/Calendar/dateIntervalOfWeekend(containing:))

Returns a `DateInterval` of the weekend contained by the given date, or `nil` if the date is not in a weekend.

[`dateIntervalOfWeekend(containing:start:interval:)`](/documentation/Foundation/Calendar/dateIntervalOfWeekend(containing:start:interval:))

Find the range of the weekend around the given date, returned via two by-reference parameters.

[`nextWeekend(startingAfter:direction:)`](/documentation/Foundation/Calendar/nextWeekend(startingAfter:direction:))

Returns a `DateInterval` of the next weekend, which starts strictly after the given date.

[`nextWeekend(startingAfter:start:interval:direction:)`](/documentation/Foundation/Calendar/nextWeekend(startingAfter:start:interval:direction:))

Returns the range of the next weekend via two inout parameters. The weekend starts strictly after the given date.

[`Calendar.SearchDirection`](/documentation/Foundation/Calendar/SearchDirection)

The direction in time to search.

### Comparing Dates

[`compare(_:to:toGranularity:)`](/documentation/Foundation/Calendar/compare(_:to:toGranularity:))

Compares two dates down to the specified component.

[`isDate(_:equalTo:toGranularity:)`](/documentation/Foundation/Calendar/isDate(_:equalTo:toGranularity:))

Returns a Boolean value indicating whether two dates are equal down to the specified component.

[`isDate(_:inSameDayAs:)`](/documentation/Foundation/Calendar/isDate(_:inSameDayAs:))

Returns a Boolean value indicating whether a date is within the same day as another date.

[`isDateInToday(_:)`](/documentation/Foundation/Calendar/isDateInToday(_:))

Returns a Boolean value indicating whether the given date is within today.

[`isDateInTomorrow(_:)`](/documentation/Foundation/Calendar/isDateInTomorrow(_:))

Returns a Boolean value indicating whether the given date is within tomorrow.

[`isDateInYesterday(_:)`](/documentation/Foundation/Calendar/isDateInYesterday(_:))

Returns a Boolean value indicating whether the given date is within yesterday.

[`isDateInWeekend(_:)`](/documentation/Foundation/Calendar/isDateInWeekend(_:))

Returns a Boolean value indicating whether the given date is within a weekend period.

### Getting AM and PM symbols

[`amSymbol`](/documentation/Foundation/Calendar/amSymbol)

The symbol used to represent “AM”, localized to the Calendar’s `locale`.

[`pmSymbol`](/documentation/Foundation/Calendar/pmSymbol)

The symbol used to represent “PM”, localized to the Calendar’s `locale`.

### Getting Weekday Symbols

[`weekdaySymbols`](/documentation/Foundation/Calendar/weekdaySymbols)

A list of weekdays in this calendar, localized to the Calendar’s `locale`.

[`shortWeekdaySymbols`](/documentation/Foundation/Calendar/shortWeekdaySymbols)

A list of shorter-named weekdays in this calendar, localized to the Calendar’s `locale`.

[`veryShortWeekdaySymbols`](/documentation/Foundation/Calendar/veryShortWeekdaySymbols)

A list of very-shortly-named weekdays in this calendar, localized to the Calendar’s `locale`.

[`standaloneWeekdaySymbols`](/documentation/Foundation/Calendar/standaloneWeekdaySymbols)

A list of standalone weekday names in this calendar, localized to the Calendar’s `locale`.

[`shortStandaloneWeekdaySymbols`](/documentation/Foundation/Calendar/shortStandaloneWeekdaySymbols)

A list of shorter-named standalone weekdays in this calendar, localized to the Calendar’s `locale`.

[`veryShortStandaloneWeekdaySymbols`](/documentation/Foundation/Calendar/veryShortStandaloneWeekdaySymbols)

A list of very-shortly-named weekdays in this calendar, localized to the Calendar’s `locale`.

### Getting Month Symbols

[`monthSymbols`](/documentation/Foundation/Calendar/monthSymbols)

A list of months in this calendar, localized to the Calendar’s `locale`.

[`shortMonthSymbols`](/documentation/Foundation/Calendar/shortMonthSymbols)

A list of shorter-named months in this calendar, localized to the Calendar’s `locale`.

[`veryShortMonthSymbols`](/documentation/Foundation/Calendar/veryShortMonthSymbols)

A list of very-shortly-named months in this calendar, localized to the Calendar’s `locale`.

[`standaloneMonthSymbols`](/documentation/Foundation/Calendar/standaloneMonthSymbols)

A list of standalone months in this calendar, localized to the Calendar’s `locale`.

[`shortStandaloneMonthSymbols`](/documentation/Foundation/Calendar/shortStandaloneMonthSymbols)

A list of shorter-named standalone months in this calendar, localized to the Calendar’s `locale`.

[`veryShortStandaloneMonthSymbols`](/documentation/Foundation/Calendar/veryShortStandaloneMonthSymbols)

A list of very-shortly-named standalone months in this calendar, localized to the Calendar’s `locale`.

### Getting Quarter Symbols

[`quarterSymbols`](/documentation/Foundation/Calendar/quarterSymbols)

A list of quarter names in this calendar, localized to the Calendar’s `locale`.

[`shortQuarterSymbols`](/documentation/Foundation/Calendar/shortQuarterSymbols)

A list of shorter-named quarters in this calendar, localized to the Calendar’s `locale`.

[`standaloneQuarterSymbols`](/documentation/Foundation/Calendar/standaloneQuarterSymbols)

A list of standalone quarter names in this calendar, localized to the Calendar’s `locale`.

[`shortStandaloneQuarterSymbols`](/documentation/Foundation/Calendar/shortStandaloneQuarterSymbols)

A list of shorter-named standalone quarters in this calendar, localized to the Calendar’s `locale`.

### Getting Era Symbols

[`eraSymbols`](/documentation/Foundation/Calendar/eraSymbols)

A list of eras in this calendar, localized to the Calendar’s `locale`.

[`longEraSymbols`](/documentation/Foundation/Calendar/longEraSymbols)

A list of longer-named eras in this calendar, localized to the Calendar’s `locale`.

### Working with notification messages

[`Calendar.CalendarDayChangedMessage`](/documentation/Foundation/Calendar/CalendarDayChangedMessage)

A message sent by a calendar when the system’s calendar day changes, as determined by the system calendar, locale, and time zone.

### Using Reference Types

[`NSCalendar`](/documentation/Foundation/NSCalendar)

A definition of the relationships between calendar units and absolute points in time, providing features for calculation and comparison of dates.



---

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)