@@ -614,8 +614,7 @@ extension Calendar {
614
614
/// weekdays of intereset, or to filter a list of dates
615
615
func _weekdayComponents( for weekdays: [ Calendar . RecurrenceRule . Weekday ] ,
616
616
in parent: Calendar . Component ,
617
- anchor: Date ,
618
- anchorComponents: DateComponents ? = nil ) -> [ DateComponents ] ? {
617
+ anchor: Date ) -> [ DateComponents ] ? {
619
618
/// Map of weekdays to which occurences of the weekday we are interested
620
619
/// in. `1` is the first such weekday in the interval, `-1` is the last.
621
620
/// An empty array indicates that any weekday is valid
@@ -645,9 +644,6 @@ extension Calendar {
645
644
} else {
646
645
. weekOfYear
647
646
}
648
- /// The components we return for matching and enumeration
649
- let componentSet : Calendar . ComponentSet = [ . weekday, . hour, . minute, . second]
650
-
651
647
652
648
guard
653
649
let interval = dateInterval ( of: parent, for: anchor)
@@ -656,7 +652,6 @@ extension Calendar {
656
652
lazy var weekRange = range ( of: weekComponent, in: parent, for: anchor) !
657
653
658
654
var result : [ DateComponents ] = [ ]
659
- let anchorComponents = anchorComponents ?? _dateComponents ( componentSet, from: anchor)
660
655
661
656
lazy var firstWeekday = component ( . weekday, from: interval. start)
662
657
// The end of the interval would always be midnight on the day after, so
@@ -667,15 +662,15 @@ extension Calendar {
667
662
for (weekday, occurences) in map {
668
663
let weekdayIdx = weekday. icuIndex
669
664
if occurences == [ ] {
670
- var components = anchorComponents
665
+ var components = DateComponents ( )
671
666
components. setValue ( nil , for: weekComponent)
672
667
components. weekday = weekdayIdx
673
668
result. append ( components)
674
669
} else {
675
670
lazy var firstWeek = weekRange. lowerBound + ( weekdayIdx < firstWeekday ? 1 : 0 )
676
671
lazy var lastWeek = weekRange. upperBound - ( weekdayIdx > lastWeekday ? 1 : 0 )
677
672
for occurence in occurences {
678
- var components = anchorComponents
673
+ var components = DateComponents ( )
679
674
if occurence > 0 {
680
675
components. setValue ( firstWeek - 1 + occurence, for: weekComponent)
681
676
} else {
@@ -815,7 +810,7 @@ extension Calendar {
815
810
if let weekdays = combinationComponents. weekdays {
816
811
dates = try dates. flatMap { date, comps in
817
812
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)
819
814
let dates = try weekdayComponents!. map { comps in
820
815
var date = date
821
816
if let result = try dateAfterMatchingWeekOfYear ( startingAt: date, components: comps, direction: . forward) {
0 commit comments