Skip to content

Commit db4bab8

Browse files
authored
update expanded calendar support proposal (swiftlang#1407)
renamed isAdhikaDay to isRepeatedDay added DateComponents.swift section
1 parent f3922df commit db4bab8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

Proposals/0017-expanded-calendar-support.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Foundation will add constants to support the new calendar types.
2727

2828
Some calendars added by this proposal have a unique feature of "leap days", where two consecutive days can have the same numeric value. This new feature will have impact on APIs that search/match dates.
2929

30-
This property will be called isAdhikaDay, to indicate it is used in Hindu calendars which are the only calendars that has this feature. More details about the naming is provided in the section `Alternatives considered` at the end of the document.
30+
This property will be called `isRepeatedDay`. More details about the naming is provided in the section `Alternatives considered` at the end of the document.
3131

3232
## Detailed design
3333

@@ -86,7 +86,7 @@ Foundation will add new string constants for new calendar identifiers for NSCale
8686
}
8787
```
8888

89-
Following are the code changes required to support new calendar property isAdhikaDay
89+
Following are the code changes required to support new calendar property isRepeatedDay
9090

9191

9292
**Calendar.swift**
@@ -96,11 +96,20 @@ Following are the code changes required to support new calendar property isAdhik
9696
public enum Component : Sendable {
9797
// ...
9898
@available(FoundationPreview 6.2, *)
99-
case isAdhikaDay
99+
case isRepeatedDay
100100
// ....
101101
}
102102
```
103103

104+
**DateComponents.swift**
105+
106+
```swift
107+
extension DateComponents {
108+
@available(FoundationPreview 6.2, *)
109+
public var isRepeatedDay: Bool? { get set }
110+
}
111+
```
112+
104113
## Impact on existing code
105114

106115
Vietnamese and Korean calendars have no special considerations.
@@ -113,19 +122,17 @@ Calendars used in India are introducing the new field for the leap day. Clients
113122
var components = DateComponents()
114123
```
115124

116-
**Second**, the comparison for calendar dates will account for this field. Two dates differs if they don't have the same value for isAdhikaDay
125+
**Second**, the comparison for calendar dates will account for this field. Two dates differs if they don't have the same value for isRepeatedDay
117126

118127
For example, the clients may currently use following check
119128

120129
```swift
121130
cal.compare(d1, d2)
122131
```
123132

124-
For Hindu calendars, this would only compare equal if they're both Adhika day or if they are both not. For non-Hindu calendars, isAdhikaDay property will be ignored.
125-
126-
**Third**, the calendar date arithmetic will be updated to correctly calculate the dates regarding `adhikaDay`. When working with Hindu calendars, as the leap days can occur at any position, looking for next day would have to involve recalculation.
133+
For Hindu calendars, this would only compare equal if their year, month, day, and repeated day values are all the same. For non-Hindu calendars, isRepeatedDay property will be ignored.
127134

128-
As a general rule, behavior of `isAdhikaDay` will replicate `isLeapMonth` in APIs doing matching and searching.
135+
As a general rule, behavior of `isRepeatedDay` will replicate `isLeapMonth` in APIs doing matching and searching.
129136

130137
For example, let's explain what is the expected behavior in this API that enumerate the next date
131138

@@ -144,17 +151,17 @@ Clients using this function to enumerate the next date after `date`, matching th
144151

145152
* If start is on a leap day
146153

147-
* `strict`: If components.isAdhikaDay is true, this gives you the next date that is also a leap day that shares the same day, month, year number (i.e. all those specified with the comps argument) as start. If only a subset of `DateComponents` is specified, for example only the month, this gives you the next date which is a leap day with same month. If no arguments are given for `DateComponents`, this gives the next date that is also a leap day. If components.isAdhikaDay is false, this function gives you the next date that matches the day/month/year number but one that is not a leap day.
154+
* `strict`: If components.isRepeatedDay is true, this gives you the next date that is also a leap day that shares the same day, month, year number (i.e. all those specified with the comps argument) as start. If only a subset of `DateComponents` is specified, for example only the month, this gives you the next date which is a leap day with same month. If no arguments are given for `DateComponents`, this gives the next date that is also a leap day. If components.isRepeatedDay is false, this function gives you the next date that matches the day/month/year number but one that is not a leap day.
148155

149156
* If start is not on a leap day
150157

151-
* `strict`: If components.isAdhikaDay is true, this gives you the next date that is a leap day that shares the same day, month, year number (i.e. all those specified with the comps argument) as start but a leap day. If components.isAdhikaDay is false, this function gives you the next date that matches the day/month/year number that is not a leap day.
158+
* `strict`: If components.isRepeatedDay is true, this gives you the next date that is a leap day that shares the same day, month, year number (i.e. all those specified with the comps argument) as start but a leap day. If components.isRepeatedDay is false, this function gives you the next date that matches the day/month/year number that is not a leap day.
152159

153160
For the `direction` and `repeatedTimePolicy`:
154161

155162
* `backward`: This flag does not affect how leap day search is handled, but merely changes the search direction so that it finds the match before start rather than after start.
156163

157-
* `first`: If there are two or more matching dates, and all their components are the same, including isAdhikaDay, the function returns the first date.
164+
* `first`: If there are two or more matching dates, and all their components are the same, including isRepeatedDay, the function returns the first date.
158165

159166
* `last`: Similar to `first`, but the function returns the last match.
160167

@@ -178,6 +185,6 @@ public func dates(byAdding components: DateComponents,
178185

179186
As mentioned before, the leap day is a unique feature of some of new calendars. It appears when a certain astronomical position of Sun and Moon happens which means it can appear on any date. That differs from Gregorian leap day of February 29th, which happens every four years (approximately) and it is always on the same day.
180187

181-
This property will be called isAdhikaDay to clearly indicate it is related to Hindu lunisolar calendars. The alternative was to call it isLeapDay, but that may lead to confusion with Gregorian calendar
188+
This property will be called isRepeatedDay to clearly indicate it is a day that repeats. The alternatives were to call it isLeapDay which might lead to confusion with Gregorian calendar, or isAdhikaDay which would be unclear for developers unfamiliar with Hindu calendar terminology.
182189

183190
Another point of discussion was whether to use Bengali vs Bangla and Oriya vs Odia. There has been an effort to stop using the older colloquial names Bengali and Oriya and to switch to the now-accepted names Bangla and Odia. While most of the attention has gone to the language names, the same naming should also be used for the calendar names, despite them receiving less attention.

0 commit comments

Comments
 (0)