Skip to content

Commit 35a0a7e

Browse files
committed
Reorder arguments; clarify that addition is scaled, not repeated add
1 parent c9b34c0 commit 35a0a7e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Proposals/NNNN-calendar-improvements.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ extension Calendar {
6262
/// - parameter repeatedTimePolicy: Determines the behavior of the search algorithm when the input produces a time that occurs twice on a particular day.
6363
/// - parameter direction: Which direction in time to search. The default value is `.forward`, which means later in time.
6464
@available(FoundationPreview 0.4, *)
65-
public func dates(startingAt start: Date,
66-
in range: Range<Date>? = nil,
67-
matching components: DateComponents,
65+
public func dates(byMatching components: DateComponents,
66+
startingAt start: Date,
67+
in range: Range<Date>? = nil,
6868
matchingPolicy: MatchingPolicy = .nextTime,
6969
repeatedTimePolicy: RepeatedTimePolicy = .first,
7070
direction: SearchDirection = .forward) -> some (Sequence<Date> & Sendable)
@@ -75,7 +75,7 @@ And API on `Calendar` to enumerate addition with a `Sequence`:
7575

7676
```swift
7777
extension Calendar {
78-
/// Returns a sequence of `Date`s, calculated by repeatedly adding an amount of `Calendar.Component`s to a starting `Date` and then to each subsequent result.
78+
/// Returns a sequence of `Date`s, calculated by adding a scaled amount of `Calendar.Component`s to a starting `Date`.
7979
/// If a range is supplied, the sequence terminates if the next result is not contained in the range. The starting point does not need to be contained in the range, but if the first result is outside of the range then the result will be an empty sequence.
8080
///
8181
/// - parameter startingAt: The starting point of the search.
@@ -85,13 +85,13 @@ extension Calendar {
8585
/// - parameter wrappingComponents: If `true`, the component should be incremented and wrap around to zero/one on overflow, and should not cause higher components to be incremented. The default value is `false`.
8686
/// - returns: A `Sequence` of `Date` values, or an empty sequence if no addition could be performed.
8787
@available(FoundationPreview 0.4, *)
88-
public func dates(startingAt start: Date,
89-
in range: Range<Date>? = nil,
90-
byAdding component: Calendar.Component,
88+
public func dates(byAdding component: Calendar.Component,
9189
value: Int = 1,
90+
startingAt start: Date,
91+
in range: Range<Date>? = nil,
9292
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable)
9393

94-
/// Returns a sequence of `Date`s, calculated by repeatedly adding an amount of `Calendar.Component`s to a starting `Date` and then to each subsequent result.
94+
/// Returns a sequence of `Date`s, calculated by adding a scaled amount of `Calendar.Component`s to a starting `Date`.
9595
/// If a range is supplied, the sequence terminates if the next result is not contained in the range. The starting point does not need to be contained in the range, but if the first result is outside of the range then the result will be an empty sequence.
9696
///
9797
/// - parameter startingAt: The starting point of the search.
@@ -100,9 +100,9 @@ extension Calendar {
100100
/// - parameter wrappingComponents: If `true`, the component should be incremented and wrap around to zero/one on overflow, and should not cause higher components to be incremented. The default value is `false`.
101101
/// - returns: A `Sequence` of `Date` values, or an empty sequence if no addition could be performed.
102102
@available(FoundationPreview 0.4, *)
103-
public func dates(startingAt start: Date,
104-
in range: Range<Date>? = nil,
105-
byAdding components: DateComponents,
103+
public func dates(byAdding components: DateComponents,
104+
startingAt start: Date,
105+
in range: Range<Date>? = nil,
106106
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable)
107107
}
108108
```

0 commit comments

Comments
 (0)