@@ -14,7 +14,7 @@ public extension Date {
14
14
///
15
15
/// - Parameter list: list of dates
16
16
/// - Returns: a tuple with the index of the oldest date and its instance.
17
- public static func oldestIn( list: [ Date ] ) -> Date ? {
17
+ static func oldestIn( list: [ Date ] ) -> Date ? {
18
18
guard list. count > 0 else { return nil }
19
19
guard list. count > 1 else { return list. first! }
20
20
return list. min ( by: {
@@ -26,7 +26,7 @@ public extension Date {
26
26
///
27
27
/// - Parameter list: list of dates
28
28
/// - Returns: a tuple with the index of the oldest date and its instance.
29
- public static func newestIn( list: [ Date ] ) -> Date ? {
29
+ static func newestIn( list: [ Date ] ) -> Date ? {
30
30
guard list. count > 0 else { return nil }
31
31
guard list. count > 1 else { return list. first! }
32
32
return list. max ( by: {
@@ -43,7 +43,7 @@ public extension Date {
43
43
/// - endDate: ending date
44
44
/// - increment: increment function. It get the last generated date and require a valida `DateComponents` instance which define the increment
45
45
/// - Returns: array of dates
46
- public static func enumerateDates( from startDate: Date , to endDate: Date , increment: ( ( Date ) -> ( DateComponents ) ) ) -> [ Date ] {
46
+ static func enumerateDates( from startDate: Date , to endDate: Date , increment: ( ( Date ) -> ( DateComponents ) ) ) -> [ Date ] {
47
47
var dates : [ Date ] = [ ]
48
48
var currentDate = startDate
49
49
@@ -63,7 +63,7 @@ public extension Date {
63
63
/// - endDate: ending date
64
64
/// - increment: components to add
65
65
/// - Returns: array of dates
66
- public static func enumerateDates( from startDate: Date , to endDate: Date , increment: DateComponents ) -> [ Date ] {
66
+ static func enumerateDates( from startDate: Date , to endDate: Date , increment: DateComponents ) -> [ Date ] {
67
67
return Date . enumerateDates ( from: startDate, to: endDate, increment: { _ in
68
68
return increment
69
69
} )
@@ -73,15 +73,15 @@ public extension Date {
73
73
///
74
74
/// - Parameter style: rounding mode.
75
75
/// - Returns: rounded date
76
- public func dateRoundedAt( at style: RoundDateMode ) -> Date {
76
+ func dateRoundedAt( at style: RoundDateMode ) -> Date {
77
77
return inDefaultRegion ( ) . dateRoundedAt ( style) . date
78
78
}
79
79
80
80
/// Returns a new DateInRegion that is initialized at the start of a specified unit of time.
81
81
///
82
82
/// - Parameter unit: time unit value.
83
83
/// - Returns: instance at the beginning of the time unit; `self` if fails.
84
- public func dateAtStartOf( _ unit: Calendar . Component ) -> Date {
84
+ func dateAtStartOf( _ unit: Calendar . Component ) -> Date {
85
85
return inDefaultRegion ( ) . dateAtStartOf ( unit) . date
86
86
}
87
87
@@ -90,7 +90,7 @@ public extension Date {
90
90
///
91
91
/// - Parameter units: sequence of transformations as time unit components
92
92
/// - Returns: new date at the beginning of the passed components, intermediate results if fails.
93
- public func dateAtStartOf( _ units: [ Calendar . Component ] ) -> Date {
93
+ func dateAtStartOf( _ units: [ Calendar . Component ] ) -> Date {
94
94
return units. reduce ( self ) { ( currentDate, currentUnit) -> Date in
95
95
return currentDate. dateAtStartOf ( currentUnit)
96
96
}
@@ -101,7 +101,7 @@ public extension Date {
101
101
/// - parameter unit: A TimeUnit value.
102
102
///
103
103
/// - returns: A new Moment instance.
104
- public func dateAtEndOf( _ unit: Calendar . Component ) -> Date {
104
+ func dateAtEndOf( _ unit: Calendar . Component ) -> Date {
105
105
return inDefaultRegion ( ) . dateAtEndOf ( unit) . date
106
106
}
107
107
@@ -110,7 +110,7 @@ public extension Date {
110
110
///
111
111
/// - Parameter units: sequence of transformations as time unit components
112
112
/// - Returns: new date at the end of the passed components, intermediate results if fails.
113
- public func dateAtEndOf( _ units: [ Calendar . Component ] ) -> Date {
113
+ func dateAtEndOf( _ units: [ Calendar . Component ] ) -> Date {
114
114
return units. reduce ( self ) { ( currentDate, currentUnit) -> Date in
115
115
return currentDate. dateAtEndOf ( currentUnit)
116
116
}
@@ -120,7 +120,7 @@ public extension Date {
120
120
///
121
121
/// - Parameter components: components to alter with their new values.
122
122
/// - Returns: new altered `DateInRegion` instance
123
- public func dateBySet( _ components: [ Calendar . Component : Int ] ) -> Date ? {
123
+ func dateBySet( _ components: [ Calendar . Component : Int ] ) -> Date ? {
124
124
return DateInRegion ( self , region: SwiftDate . defaultRegion) . dateBySet ( components) ? . date
125
125
}
126
126
@@ -133,7 +133,7 @@ public extension Date {
133
133
/// - ms: milliseconds to set (`nil` to leave it unaltered)
134
134
/// - options: options for calculation
135
135
/// - Returns: new altered `DateInRegion` instance
136
- public func dateBySet( hour: Int ? , min: Int ? , secs: Int ? , ms: Int ? = nil , options: TimeCalculationOptions = TimeCalculationOptions ( ) ) -> Date ? {
136
+ func dateBySet( hour: Int ? , min: Int ? , secs: Int ? , ms: Int ? = nil , options: TimeCalculationOptions = TimeCalculationOptions ( ) ) -> Date ? {
137
137
let srcDate = DateInRegion ( self , region: SwiftDate . defaultRegion)
138
138
return srcDate. dateBySet ( hour: hour, min: min, secs: secs, ms: ms, options: options) ? . date
139
139
}
@@ -142,15 +142,15 @@ public extension Date {
142
142
///
143
143
/// - Parameter components: components to truncate.
144
144
/// - Returns: new date with truncated components.
145
- public func dateTruncated( _ components: [ Calendar . Component ] ) -> Date ? {
145
+ func dateTruncated( _ components: [ Calendar . Component ] ) -> Date ? {
146
146
return DateInRegion ( self , region: SwiftDate . defaultRegion) . dateTruncated ( at: components) ? . date
147
147
}
148
148
149
149
/// Creates a new instance by truncating the components starting from given components down the granurality.
150
150
///
151
151
/// - Parameter component: The component to be truncated from.
152
152
/// - Returns: new date with truncated components.
153
- public func dateTruncated( from component: Calendar . Component ) -> Date ? {
153
+ func dateTruncated( from component: Calendar . Component ) -> Date ? {
154
154
return DateInRegion ( self , region: SwiftDate . defaultRegion) . dateTruncated ( from: component) ? . date
155
155
}
156
156
@@ -161,23 +161,23 @@ public extension Date {
161
161
/// - count: value of the offset.
162
162
/// - component: component to offset.
163
163
/// - Returns: new altered date.
164
- public func dateByAdding( _ count: Int , _ component: Calendar . Component ) -> DateInRegion {
164
+ func dateByAdding( _ count: Int , _ component: Calendar . Component ) -> DateInRegion {
165
165
return DateInRegion ( self , region: SwiftDate . defaultRegion) . dateByAdding ( count, component)
166
166
}
167
167
168
168
/// Return related date starting from the receiver attributes.
169
169
///
170
170
/// - Parameter type: related date to obtain.
171
171
/// - Returns: instance of the related date.
172
- public func dateAt( _ type: DateRelatedType ) -> Date {
172
+ func dateAt( _ type: DateRelatedType ) -> Date {
173
173
return inDefaultRegion ( ) . dateAt ( type) . date
174
174
}
175
175
176
176
/// Create a new date at now and extract the related date using passed rule type.
177
177
///
178
178
/// - Parameter type: related date to obtain.
179
179
/// - Returns: instance of the related date.
180
- public static func nowAt( _ type: DateRelatedType ) -> Date {
180
+ static func nowAt( _ type: DateRelatedType ) -> Date {
181
181
return Date ( ) . dateAt ( type)
182
182
}
183
183
@@ -191,7 +191,7 @@ public extension Date {
191
191
/// - year: year target.
192
192
/// - region: region target, omit to use `SwiftDate.defaultRegion`
193
193
/// - Returns: Ordered list of the dates for given weekday into given month.
194
- public static func datesForWeekday( _ weekday: WeekDay , inMonth month: Int , ofYear year: Int ,
194
+ static func datesForWeekday( _ weekday: WeekDay , inMonth month: Int , ofYear year: Int ,
195
195
region: Region = SwiftDate . defaultRegion) -> [ Date ] {
196
196
let fromDate = DateInRegion ( Date ( year: year, month: month, day: 1 , hour: 0 , minute: 0 ) , region: region)
197
197
let toDate = fromDate. dateAt ( . endOfMonth)
@@ -207,7 +207,7 @@ public extension Date {
207
207
/// - endDate: to date of the range.
208
208
/// - region: region target, omit to use `SwiftDate.defaultRegion`
209
209
/// - Returns: Ordered list of the dates for given weekday in passed range.
210
- public static func datesForWeekday( _ weekday: WeekDay , from startDate: Date , to endDate: Date ,
210
+ static func datesForWeekday( _ weekday: WeekDay , from startDate: Date , to endDate: Date ,
211
211
region: Region = SwiftDate . defaultRegion) -> [ Date ] {
212
212
let fromDate = DateInRegion ( startDate, region: region)
213
213
let toDate = DateInRegion ( endDate, region: region)
0 commit comments