@@ -67,7 +67,7 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab
67
67
private func _getter( _ x : Int ) -> Int ? { return x == NSDateComponentUndefined ? nil : x }
68
68
69
69
/// Translate from the proper Swift optional value into an NSDateComponentUndefined
70
- private func _setter( _ x : Int ? ) -> Int { if let xx = x { return xx } else { return NSDateComponentUndefined } }
70
+ private static func _setter( _ x : Int ? ) -> Int { if let xx = x { return xx } else { return NSDateComponentUndefined } }
71
71
72
72
/// The `Calendar` used to interpret the other values in this structure.
73
73
///
@@ -88,92 +88,92 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab
88
88
/// - note: This value is interpreted in the context of the calendar in which it is used.
89
89
public var era : Int ? {
90
90
get { return _handle. map { _getter ( $0. era) } }
91
- set { _applyMutation { $0. era = _setter ( newValue) } }
91
+ set { _applyMutation { $0. era = DateComponents . _setter ( newValue) } }
92
92
}
93
93
94
94
/// A year or count of years.
95
95
/// - note: This value is interpreted in the context of the calendar in which it is used.
96
96
public var year : Int ? {
97
97
get { return _handle. map { _getter ( $0. year) } }
98
- set { _applyMutation { $0. year = _setter ( newValue) } }
98
+ set { _applyMutation { $0. year = DateComponents . _setter ( newValue) } }
99
99
}
100
100
101
101
/// A month or count of months.
102
102
/// - note: This value is interpreted in the context of the calendar in which it is used.
103
103
public var month : Int ? {
104
104
get { return _handle. map { _getter ( $0. month) } }
105
- set { _applyMutation { $0. month = _setter ( newValue) } }
105
+ set { _applyMutation { $0. month = DateComponents . _setter ( newValue) } }
106
106
}
107
107
108
108
/// A day or count of days.
109
109
/// - note: This value is interpreted in the context of the calendar in which it is used.
110
110
public var day : Int ? {
111
111
get { return _handle. map { _getter ( $0. day) } }
112
- set { _applyMutation { $0. day = _setter ( newValue) } }
112
+ set { _applyMutation { $0. day = DateComponents . _setter ( newValue) } }
113
113
}
114
114
115
115
/// An hour or count of hours.
116
116
/// - note: This value is interpreted in the context of the calendar in which it is used.
117
117
public var hour : Int ? {
118
118
get { return _handle. map { _getter ( $0. hour) } }
119
- set { _applyMutation { $0. hour = _setter ( newValue) } }
119
+ set { _applyMutation { $0. hour = DateComponents . _setter ( newValue) } }
120
120
}
121
121
122
122
/// A minute or count of minutes.
123
123
/// - note: This value is interpreted in the context of the calendar in which it is used.
124
124
public var minute : Int ? {
125
125
get { return _handle. map { _getter ( $0. minute) } }
126
- set { _applyMutation { $0. minute = _setter ( newValue) } }
126
+ set { _applyMutation { $0. minute = DateComponents . _setter ( newValue) } }
127
127
}
128
128
129
129
/// A second or count of seconds.
130
130
/// - note: This value is interpreted in the context of the calendar in which it is used.
131
131
public var second : Int ? {
132
132
get { return _handle. map { _getter ( $0. second) } }
133
- set { _applyMutation { $0. second = _setter ( newValue) } }
133
+ set { _applyMutation { $0. second = DateComponents . _setter ( newValue) } }
134
134
}
135
135
136
136
/// A nanosecond or count of nanoseconds.
137
137
/// - note: This value is interpreted in the context of the calendar in which it is used.
138
138
public var nanosecond : Int ? {
139
139
get { return _handle. map { _getter ( $0. nanosecond) } }
140
- set { _applyMutation { $0. nanosecond = _setter ( newValue) } }
140
+ set { _applyMutation { $0. nanosecond = DateComponents . _setter ( newValue) } }
141
141
}
142
142
143
143
/// A weekday or count of weekdays.
144
144
/// - note: This value is interpreted in the context of the calendar in which it is used.
145
145
public var weekday : Int ? {
146
146
get { return _handle. map { _getter ( $0. weekday) } }
147
- set { _applyMutation { $0. weekday = _setter ( newValue) } }
147
+ set { _applyMutation { $0. weekday = DateComponents . _setter ( newValue) } }
148
148
}
149
149
150
150
/// A weekday ordinal or count of weekday ordinals.
151
151
/// Weekday ordinal units represent the position of the weekday within the next larger calendar unit, such as the month. For example, 2 is the weekday ordinal unit for the second Friday of the month.///
152
152
/// - note: This value is interpreted in the context of the calendar in which it is used.
153
153
public var weekdayOrdinal : Int ? {
154
154
get { return _handle. map { _getter ( $0. weekdayOrdinal) } }
155
- set { _applyMutation { $0. weekdayOrdinal = _setter ( newValue) } }
155
+ set { _applyMutation { $0. weekdayOrdinal = DateComponents . _setter ( newValue) } }
156
156
}
157
157
158
158
/// A quarter or count of quarters.
159
159
/// - note: This value is interpreted in the context of the calendar in which it is used.
160
160
public var quarter : Int ? {
161
161
get { return _handle. map { _getter ( $0. quarter) } }
162
- set { _applyMutation { $0. quarter = _setter ( newValue) } }
162
+ set { _applyMutation { $0. quarter = DateComponents . _setter ( newValue) } }
163
163
}
164
164
165
165
/// A week of the month or a count of weeks of the month.
166
166
/// - note: This value is interpreted in the context of the calendar in which it is used.
167
167
public var weekOfMonth : Int ? {
168
168
get { return _handle. map { _getter ( $0. weekOfMonth) } }
169
- set { _applyMutation { $0. weekOfMonth = _setter ( newValue) } }
169
+ set { _applyMutation { $0. weekOfMonth = DateComponents . _setter ( newValue) } }
170
170
}
171
171
172
172
/// A week of the year or count of the weeks of the year.
173
173
/// - note: This value is interpreted in the context of the calendar in which it is used.
174
174
public var weekOfYear : Int ? {
175
175
get { return _handle. map { _getter ( $0. weekOfYear) } }
176
- set { _applyMutation { $0. weekOfYear = _setter ( newValue) } }
176
+ set { _applyMutation { $0. weekOfYear = DateComponents . _setter ( newValue) } }
177
177
}
178
178
179
179
/// The ISO 8601 week-numbering year of the receiver.
@@ -184,7 +184,7 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab
184
184
/// - note: This value is interpreted in the context of the calendar in which it is used.
185
185
public var yearForWeekOfYear : Int ? {
186
186
get { return _handle. map { _getter ( $0. yearForWeekOfYear) } }
187
- set { _applyMutation { $0. yearForWeekOfYear = _setter ( newValue) } }
187
+ set { _applyMutation { $0. yearForWeekOfYear = DateComponents . _setter ( newValue) } }
188
188
}
189
189
190
190
/// Set to true if these components represent a leap month.
@@ -219,7 +219,7 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab
219
219
@available ( macOS 10 . 9 , iOS 8 . 0 , * )
220
220
public mutating func setValue( _ value: Int ? , for component: Calendar . Component ) {
221
221
_applyMutation {
222
- $0. setValue ( _setter ( value) , forComponent: Calendar . _toCalendarUnit ( [ component] ) )
222
+ $0. setValue ( DateComponents . _setter ( value) , forComponent: Calendar . _toCalendarUnit ( [ component] ) )
223
223
}
224
224
}
225
225
0 commit comments