func recurrences(of start: Date, in range: ClosedRange<Date>) -> some Sendable & Sequence<Date>
Find recurrences of the given date
The calculations are implemented according to RFC-5545 and RFC-7529.
- Parameter start: the date which defines the starting point for the
recurrence rule.
- Parameter range: a range of dates which to search for recurrences.
- Returns: a sequence of dates conforming to the recurrence rule, in
the given `range`. An empty sequence if the rule doesn't match any
dates.
func recurrences(of start: Date, in range: Range<Date>? = nil) -> some Sendable & Sequence<Date>
Find recurrences of the given date
The calculations are implemented according to RFC-5545 and RFC-7529.
- Parameter start: the date which defines the starting point for the
recurrence rule.
- Parameter range: a range of dates which to search for recurrences.
If `nil`, return all recurrences of the event.
- Returns: a sequence of dates conforming to the recurrence rule, in
the given `range`. An empty sequence if the rule doesn't match any
dates.
func recurrences(of start: Date, in range: PartialRangeFrom<Date>) -> some Sendable & Sequence<Date>
Find recurrences of the given date
The calculations are implemented according to RFC-5545 and RFC-7529.
- Parameter start: the date which defines the starting point for the
recurrence rule.
- Parameter range: a range of dates which to search for recurrences.
- Returns: a sequence of dates conforming to the recurrence rule, in
the given `range`. An empty sequence if the rule doesn't match any
dates.
func recurrences(of start: Date, in range: PartialRangeUpTo<Date>) -> some Sendable & Sequence<Date>
Find recurrences of the given date
The calculations are implemented according to RFC-5545 and RFC-7529.
- Parameter start: the date which defines the starting point for the
recurrence rule.
- Parameter range: a range of dates which to search for recurrences.
- Returns: a sequence of dates conforming to the recurrence rule, in
the given `range`. An empty sequence if the rule doesn't match any
dates.
func recurrences(of start: Date, in range: PartialRangeThrough<Date>) -> some Sendable & Sequence<Date>
Find recurrences of the given date
The calculations are implemented according to RFC-5545 and RFC-7529.
- Parameter start: the date which defines the starting point for the
recurrence rule.
- Parameter range: a range of dates which to search for recurrences.
- Returns: a sequence of dates conforming to the recurrence rule, in
the given `range`. An empty sequence if the rule doesn't match any
dates.
get · iOS 18.0+
setPositions
TypeScript
get setPositions(): Array<number>
Swift declaration
var setPositions: [Int]
Which occurrences within every interval should be returned
set · iOS 18.0+
setPositions
TypeScript
set setPositions(value: Array<number>)
Swift declaration
var setPositions: [Int]
Which occurrences within every interval should be returned
get · iOS 18.0+
daysOfTheYear
TypeScript
get daysOfTheYear(): Array<number>
Swift declaration
var daysOfTheYear: [Int]
On which days of the year the event may occur.
- 1 signifies the first day of the year.
- Negative values point to a day counted backwards from the last day
of the year
This field is unused when `frequency` is any of `.daily`, `.weekly`,
or `.monthly`.
set · iOS 18.0+
daysOfTheYear
TypeScript
set daysOfTheYear(value: Array<number>)
Swift declaration
var daysOfTheYear: [Int]
On which days of the year the event may occur.
- 1 signifies the first day of the year.
- Negative values point to a day counted backwards from the last day
of the year
This field is unused when `frequency` is any of `.daily`, `.weekly`,
or `.monthly`.
get · iOS 18.0+
daysOfTheMonth
TypeScript
get daysOfTheMonth(): Array<number>
Swift declaration
var daysOfTheMonth: [Int]
On which days in the month the event should occur
- 1 signifies the first day of the month.
- Negative values point to a day counted backwards from the last day
of the month
This field is unused when `frequency` is `.weekly`.
set · iOS 18.0+
daysOfTheMonth
TypeScript
set daysOfTheMonth(value: Array<number>)
Swift declaration
var daysOfTheMonth: [Int]
On which days in the month the event should occur
- 1 signifies the first day of the month.
- Negative values point to a day counted backwards from the last day
of the month
This field is unused when `frequency` is `.weekly`.
get · iOS 18.0+
matchingPolicy
TypeScript
get matchingPolicy(): Calendar_MatchingPolicy
Swift declaration
var matchingPolicy: Calendar.MatchingPolicy
What to do when a recurrence is not a valid date
An occurrence may not be a valid date if it falls on a leap day or a
leap hour when there is not one. When that happens, we can choose to
ignore the occurrence (`.strict`), choose a later time which has the
same components (`.nextTimePreservingSmallerComponents`), or find an
earlier time (`.previousTimePreservingSmallerComponents`).
For example, consider an event happening every year, starting on the
29th of February 2020. When the matching policy is set to `.strict`,
it yields the following recurrences:
- 2020-02-29
- 2024-02-29
- 2028-02-29
- ...
With `matchingPolicy` of `.previousTimePreservingSmallerComponents`,
we get a result for each year:
- 2020-02-29
- 2021-02-28
- 2022-02-28
- 2023-02-28
- 2024-02-29
Lastly, a `matchingPolicy` of `.nextTimePreservingSmallerComponents`
moves invalid occurrences to the day after February 29:
- 2020-02-29
- 2021-03-01
- 2022-03-01
- 2023-03-01
- 2024-02-29
The same logic applies for missing leap hours during daylight saving
time switches. For example, consider an event repeating daily, which
starts at March 9 2024, 01:30 PST. With a `.strict` matching policy,
the event repeats on the following dates, and skips a day:
- 2024-03-09 01:30 PST (09:30 UTC)
(on 2024-03-10, there is a missing hour between 1am and 2am)
- 2024-03-11 01:30 PDT (08:30 UTC)
- 2024-03-12 01:30 PDT (08:30 UTC)
With `matchingPolicy` of `.previousTimePreservingSmallerComponents`,
we get a result for each day:
- 2024-03-09 01:30 PST (09:30 UTC)
- 2024-03-10 02:30 PST (10:30 UTC)
(on 2024-03-10, there is a missing hour between 1am and 2am)
- 2024-03-11 01:30 PDT (08:30 UTC)
- 2024-03-12 01:30 PDT (08:30 UTC)
Lastly, a `matchingPolicy` of `.nextTimePreservingSmallerComponents`
moves invalid occurrences an hour forward:
- 2024-03-09 01:30 PST (09:30 UTC)
- 2024-03-10 00:30 PST (08:30 UTC)
(on 2024-03-10, there is a missing hour between 1am and 2am)
- 2024-03-11 01:30 PDT (08:30 UTC)
- 2024-03-12 01:30 PDT (08:30 UTC)
Default value is `.nextTimePreservingSmallerComponents`
set · iOS 18.0+
matchingPolicy
TypeScript
set matchingPolicy(value: Calendar_MatchingPolicy)
Swift declaration
var matchingPolicy: Calendar.MatchingPolicy
What to do when a recurrence is not a valid date
An occurrence may not be a valid date if it falls on a leap day or a
leap hour when there is not one. When that happens, we can choose to
ignore the occurrence (`.strict`), choose a later time which has the
same components (`.nextTimePreservingSmallerComponents`), or find an
earlier time (`.previousTimePreservingSmallerComponents`).
For example, consider an event happening every year, starting on the
29th of February 2020. When the matching policy is set to `.strict`,
it yields the following recurrences:
- 2020-02-29
- 2024-02-29
- 2028-02-29
- ...
With `matchingPolicy` of `.previousTimePreservingSmallerComponents`,
we get a result for each year:
- 2020-02-29
- 2021-02-28
- 2022-02-28
- 2023-02-28
- 2024-02-29
Lastly, a `matchingPolicy` of `.nextTimePreservingSmallerComponents`
moves invalid occurrences to the day after February 29:
- 2020-02-29
- 2021-03-01
- 2022-03-01
- 2023-03-01
- 2024-02-29
The same logic applies for missing leap hours during daylight saving
time switches. For example, consider an event repeating daily, which
starts at March 9 2024, 01:30 PST. With a `.strict` matching policy,
the event repeats on the following dates, and skips a day:
- 2024-03-09 01:30 PST (09:30 UTC)
(on 2024-03-10, there is a missing hour between 1am and 2am)
- 2024-03-11 01:30 PDT (08:30 UTC)
- 2024-03-12 01:30 PDT (08:30 UTC)
With `matchingPolicy` of `.previousTimePreservingSmallerComponents`,
we get a result for each day:
- 2024-03-09 01:30 PST (09:30 UTC)
- 2024-03-10 02:30 PST (10:30 UTC)
(on 2024-03-10, there is a missing hour between 1am and 2am)
- 2024-03-11 01:30 PDT (08:30 UTC)
- 2024-03-12 01:30 PDT (08:30 UTC)
Lastly, a `matchingPolicy` of `.nextTimePreservingSmallerComponents`
moves invalid occurrences an hour forward:
- 2024-03-09 01:30 PST (09:30 UTC)
- 2024-03-10 00:30 PST (08:30 UTC)
(on 2024-03-10, there is a missing hour between 1am and 2am)
- 2024-03-11 01:30 PDT (08:30 UTC)
- 2024-03-12 01:30 PDT (08:30 UTC)
Default value is `.nextTimePreservingSmallerComponents`
get · iOS 18.0+
repeatedTimePolicy
TypeScript
get repeatedTimePolicy(): Calendar_RepeatedTimePolicy
Swift declaration
var repeatedTimePolicy: Calendar.RepeatedTimePolicy
What to do when there are multiple recurrences occurring at the same
time of the day but in different time zones due to a daylight saving
transition.
For example, an event with daily recurrence rule that starts at 1 am
on November 2 in PDT will repeat on:
- 2024-11-02 01:00 PDT (08:00 UTC)
- 2024-11-03 01:00 PDT (08:00 UTC), if `repeatedTimePolicy = .first`
(Time zone switches from PST to PDT - clock jumps back one hour at
02:00 PDT)
- 2024-11-03 01:00 PST (09:00 UTC), if `repeatedTimePolicy = .last`
- 2024-11-04 01:00 PST (09:00 UTC)
Due to the time zone switch on November 3, there are different times
when the event might repeat.
Default value is `.first`
set · iOS 18.0+
repeatedTimePolicy
TypeScript
set repeatedTimePolicy(value: Calendar_RepeatedTimePolicy)
Swift declaration
var repeatedTimePolicy: Calendar.RepeatedTimePolicy
What to do when there are multiple recurrences occurring at the same
time of the day but in different time zones due to a daylight saving
transition.
For example, an event with daily recurrence rule that starts at 1 am
on November 2 in PDT will repeat on:
- 2024-11-02 01:00 PDT (08:00 UTC)
- 2024-11-03 01:00 PDT (08:00 UTC), if `repeatedTimePolicy = .first`
(Time zone switches from PST to PDT - clock jumps back one hour at
02:00 PDT)
- 2024-11-03 01:00 PST (09:00 UTC), if `repeatedTimePolicy = .last`
- 2024-11-04 01:00 PST (09:00 UTC)
Due to the time zone switch on November 3, there are different times
when the event might repeat.
Default value is `.first`
get · iOS 18.0+
end
TypeScript
get end(): Calendar_RecurrenceRule_End
Swift declaration
var end: Calendar.RecurrenceRule.End
For how long the event repeats
Default value is `.never`
set · iOS 18.0+
end
TypeScript
set end(value: Calendar_RecurrenceRule_End)
Swift declaration
var end: Calendar.RecurrenceRule.End
For how long the event repeats
Default value is `.never`
On which hours of a 24-hour day the event should repeat.
set · iOS 18.0+
hours
TypeScript
set hours(value: Array<number>)
Swift declaration
var hours: [Int]
On which hours of a 24-hour day the event should repeat.
get · iOS 18.0+
weeks
TypeScript
get weeks(): Array<number>
Swift declaration
var weeks: [Int]
On which weeks of the year the event should occur.
- 1 is the first week of the year. `calendar.minimumDaysInFirstWeek`
defines which week is considered first.
- Negative values refer to weeks if counting backwards from the last
week of the year. -1 is the last week of the year.
This field is unused when `frequency` is other than `.yearly`.
set · iOS 18.0+
weeks
TypeScript
set weeks(value: Array<number>)
Swift declaration
var weeks: [Int]
On which weeks of the year the event should occur.
- 1 is the first week of the year. `calendar.minimumDaysInFirstWeek`
defines which week is considered first.
- Negative values refer to weeks if counting backwards from the last
week of the year. -1 is the last week of the year.
This field is unused when `frequency` is other than `.yearly`.