@@ -614,8 +614,7 @@ extension Calendar {
614614 /// weekdays of intereset, or to filter a list of dates
615615 func _weekdayComponents( for weekdays: [ Calendar . RecurrenceRule . Weekday ] ,
616616 in parent: Calendar . Component ,
617- anchor: Date ,
618- anchorComponents: DateComponents ? = nil ) -> [ DateComponents ] ? {
617+ anchor: Date ) -> [ DateComponents ] ? {
619618 /// Map of weekdays to which occurences of the weekday we are interested
620619 /// in. `1` is the first such weekday in the interval, `-1` is the last.
621620 /// An empty array indicates that any weekday is valid
@@ -645,9 +644,6 @@ extension Calendar {
645644 } else {
646645 . weekOfYear
647646 }
648- /// The components we return for matching and enumeration
649- let componentSet : Calendar . ComponentSet = [ . weekday, . hour, . minute, . second]
650-
651647
652648 guard
653649 let interval = dateInterval ( of: parent, for: anchor)
@@ -656,7 +652,6 @@ extension Calendar {
656652 lazy var weekRange = range ( of: weekComponent, in: parent, for: anchor) !
657653
658654 var result : [ DateComponents ] = [ ]
659- let anchorComponents = anchorComponents ?? _dateComponents ( componentSet, from: anchor)
660655
661656 lazy var firstWeekday = component ( . weekday, from: interval. start)
662657 // The end of the interval would always be midnight on the day after, so
@@ -667,15 +662,15 @@ extension Calendar {
667662 for (weekday, occurences) in map {
668663 let weekdayIdx = weekday. icuIndex
669664 if occurences == [ ] {
670- var components = anchorComponents
665+ var components = DateComponents ( )
671666 components. setValue ( nil , for: weekComponent)
672667 components. weekday = weekdayIdx
673668 result. append ( components)
674669 } else {
675670 lazy var firstWeek = weekRange. lowerBound + ( weekdayIdx < firstWeekday ? 1 : 0 )
676671 lazy var lastWeek = weekRange. upperBound - ( weekdayIdx > lastWeekday ? 1 : 0 )
677672 for occurence in occurences {
678- var components = anchorComponents
673+ var components = DateComponents ( )
679674 if occurence > 0 {
680675 components. setValue ( firstWeek - 1 + occurence, for: weekComponent)
681676 } else {
@@ -815,7 +810,7 @@ extension Calendar {
815810 if let weekdays = combinationComponents. weekdays {
816811 dates = try dates. flatMap { date, comps in
817812 let parentComponent : Calendar . Component = . month
818- let weekdayComponents = _weekdayComponents ( for: weekdays, in: parentComponent, anchor: date, anchorComponents : comps )
813+ let weekdayComponents = _weekdayComponents ( for: weekdays, in: parentComponent, anchor: date)
819814 let dates = try weekdayComponents!. map { comps in
820815 var date = date
821816 if let result = try dateAfterMatchingWeekOfYear ( startingAt: date, components: comps, direction: . forward) {
0 commit comments