Skip to content

Commit 89774a1

Browse files
committed
Merge branch 'release/6.0.3'
2 parents a462ce3 + 54e6c37 commit 89774a1

297 files changed

Lines changed: 26250 additions & 32117 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode10.1
2+
osx_image: xcode10.2
33

44
env:
55
global:
@@ -11,8 +11,8 @@ env:
1111
- TVOS_FRAMEWORK_SCHEME="SwiftDate-tvOS"
1212
- WATCHOS_FRAMEWORK_SCHEME="SwiftDate-watchOS"
1313
matrix:
14-
- DESTINATION="OS=11.3,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME"
15-
- DESTINATION="OS=11.3,name=Apple TV 4K" SCHEME="$TVOS_FRAMEWORK_SCHEME"
14+
- DESTINATION="OS=12.2,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME"
15+
- DESTINATION="OS=12.2,name=Apple TV 4K" SCHEME="$TVOS_FRAMEWORK_SCHEME"
1616
- DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME"
1717

1818
script:

Documentation/0.Informations.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![](./SwiftDate.png)
1+
![](./SwiftDateArt.png)
22

33
<a name="introduction"/>
44

@@ -34,6 +34,7 @@ If you ever find a test case that is incomplete, please open an issue so we can
3434
<a name="futureplans"/>
3535

3636
<a name="linux"/>
37+
3738
## Linux Compatibility
3839

3940
Since SwiftDate 5.0.13 the package compile successfully on Linux environment with the latest Swift 4.2 snapshot.

Documentation/3.Manipulate_Date.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
- [3.11 - Enumerate Dates for Weekday in Range](3.Manipulate_Date.md#enumerateweekdays)
2323
- [3.12 - Random Dates](3.Manipulate_Date.md#randomdates)
2424
- [3.13 - Sort Dates](3.Manipulate_Date.md#sort)
25+
- [3.14 - Get the next weekday](3.Manipulate_Date.md#nextWeekDay)
26+
- [3.15 - Get date at given week number/weekday](3.Manipulate_Date.md#dateAtWeeknumberWeekday)
2527

2628
Dates can be manipulated as you need by using classic math operators and readable time units.
2729

@@ -479,4 +481,28 @@ let oldestDate = DateInRegion.oldestIn(list: arrayOfDates)
479481

480482
[^ Top](#index)
481483

484+
<a name="nextWeekDay"/>
485+
486+
## 3.14 - Get the next weekday
487+
488+
In order to get the next weekday preserving smaller components (hour, minute, seconds) you can use the `nextWeekday()` function:
489+
490+
```swift
491+
let date1 = DateInRegion("2019-05-11 00:00:00", format: dateFormat, region: regionRome)!
492+
let nextFriday = date1.nextWeekday(.friday) // 2019-05-17T00:00:00+02:00
493+
```
494+
495+
[^ Top](#index)
496+
497+
<a name="dateAtWeeknumberWeekday"/>
498+
499+
## 3.15 - Get date at given week number/weekday
500+
501+
To returns the date at the given week number and week day preserving smaller components (hour, minute, seconds) you can use the `dateAt(weekdayOrdinal:weekday:monthNumber:yearNumber:)` function:
502+
503+
```swift
504+
let date = DateInRegion("2019-05-11 00:00:00", format: dateFormat, region: regionRome)!
505+
let _ = date1.dateAt(weekdayOrdinal: 3, weekday: .friday, monthNumber: date1.month + 1) // 2019-06-21T00:00:00+02:00
506+
```
507+
482508
[**Next Chapter**: Compare Dates](#4.CompareDates.md)

Documentation/Index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ The following documentation explore all the major features of the library. If yo
5252
- [3.11 - Enumerate Dates for Weekday in Range](3.Manipulate_Date.md#enumerateweekdays)
5353
- [3.12 - Random Dates](3.Manipulate_Date.md#randomdates)
5454
- [3.13 - Sort Dates](3.Manipulate_Date.md#sort)
55+
- [3.14 - Get the next weekday](3.Manipulate_Date.md#nextWeekDay)
56+
- [3.15 - Get date at given week number/weekday](3.Manipulate_Date.md#dateAtWeeknumberWeekday)
5557

5658
### [4 - Compare Dates](4.Compare_Dates.md)
5759

Sources/SwiftDate/Date/Date+Compare.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//
2-
// Date+Compare.swift
32
// SwiftDate
3+
// Parse, validate, manipulate, and display dates, time and timezones in Swift
44
//
5-
// Created by Daniele Margutti on 07/06/2018.
6-
// Copyright © 2018 SwiftDate. All rights reserved.
5+
// Created by Daniele Margutti
6+
// - Web: https://www.danielemargutti.com
7+
// - Twitter: https://twitter.com/danielemargutti
8+
// - Mail: hello@danielemargutti.com
9+
//
10+
// Copyright © 2019 Daniele Margutti. Licensed under MIT License.
711
//
812

913
import Foundation

Sources/SwiftDate/Date/Date+Components.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//
2-
// Date+Components.swift
32
// SwiftDate
3+
// Parse, validate, manipulate, and display dates, time and timezones in Swift
44
//
5-
// Created by Daniele Margutti on 07/06/2018.
6-
// Copyright © 2018 SwiftDate. All rights reserved.
5+
// Created by Daniele Margutti
6+
// - Web: https://www.danielemargutti.com
7+
// - Twitter: https://twitter.com/danielemargutti
8+
// - Mail: hello@danielemargutti.com
9+
//
10+
// Copyright © 2019 Daniele Margutti. Licensed under MIT License.
711
//
812

913
import Foundation

Sources/SwiftDate/Date/Date+Create.swift

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//
2-
// Date+Operations.swift
32
// SwiftDate
3+
// Parse, validate, manipulate, and display dates, time and timezones in Swift
44
//
5-
// Created by Daniele Margutti on 06/06/2018.
6-
// Copyright © 2018 SwiftDate. All rights reserved.
5+
// Created by Daniele Margutti
6+
// - Web: https://www.danielemargutti.com
7+
// - Twitter: https://twitter.com/danielemargutti
8+
// - Mail: hello@danielemargutti.com
9+
//
10+
// Copyright © 2019 Daniele Margutti. Licensed under MIT License.
711
//
812

913
import Foundation
@@ -22,7 +26,7 @@ public extension Date {
2226
})
2327
}
2428

25-
/// Return the oldest date in given list.
29+
/// Return the newest date in given list.
2630
///
2731
/// - Parameter list: list of dates
2832
/// - Returns: a tuple with the index of the oldest date and its instance.
@@ -214,4 +218,33 @@ public extension Date {
214218
return DateInRegion.datesForWeekday(weekday, from: fromDate, to: toDate, region: region).map { $0.date }
215219
}
216220

221+
/// Returns the date at the given week number and week day preserving smaller components (hour, minute, seconds)
222+
///
223+
/// For example: to get the third friday of next month
224+
/// let today = DateInRegion()
225+
/// let result = today.dateAt(weekdayOrdinal: 3, weekday: .friday, monthNumber: today.month + 1)
226+
///
227+
/// - Parameters:
228+
/// - weekdayOrdinal: the week number (by set position in a recurrence rule)
229+
/// - weekday: WeekDay
230+
/// - monthNumber: a number from 1 to 12 representing the month, optional parameter
231+
/// - yearNumber: a number representing the year, optional parameter
232+
/// - Returns: new date created with the given parameters
233+
func dateAt(weekdayOrdinal: Int, weekday: WeekDay, monthNumber: Int? = nil,
234+
yearNumber: Int? = nil) -> Date {
235+
let date = DateInRegion(self, region: region)
236+
return date.dateAt(weekdayOrdinal: weekdayOrdinal, weekday: weekday, monthNumber: monthNumber, yearNumber: yearNumber).date
237+
}
238+
239+
/// Returns the next weekday preserving smaller components (hour, minute, seconds)
240+
///
241+
/// - Parameters:
242+
/// - weekday: weekday to get.
243+
/// - region: region target, omit to use `SwiftDate.defaultRegion`
244+
/// - Returns: `Date`
245+
func nextWeekday(_ weekday: WeekDay, region: Region = SwiftDate.defaultRegion) -> Date {
246+
let date = DateInRegion(self, region: region)
247+
return date.nextWeekday(weekday).date
248+
}
249+
217250
}

Sources/SwiftDate/Date/Date+Math.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//
2-
// Date+Math.swift
32
// SwiftDate
3+
// Parse, validate, manipulate, and display dates, time and timezones in Swift
44
//
5-
// Created by Daniele Margutti on 07/06/2018.
6-
// Copyright © 2018 SwiftDate. All rights reserved.
5+
// Created by Daniele Margutti
6+
// - Web: https://www.danielemargutti.com
7+
// - Twitter: https://twitter.com/danielemargutti
8+
// - Mail: hello@danielemargutti.com
9+
//
10+
// Copyright © 2019 Daniele Margutti. Licensed under MIT License.
711
//
812

913
import Foundation

Sources/SwiftDate/Date/Date.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//
2-
// Date.swift
32
// SwiftDate
3+
// Parse, validate, manipulate, and display dates, time and timezones in Swift
44
//
5-
// Created by Daniele Margutti on 06/06/2018.
6-
// Copyright © 2018 SwiftDate. All rights reserved.
5+
// Created by Daniele Margutti
6+
// - Web: https://www.danielemargutti.com
7+
// - Twitter: https://twitter.com/danielemargutti
8+
// - Mail: hello@danielemargutti.com
9+
//
10+
// Copyright © 2019 Daniele Margutti. Licensed under MIT License.
711
//
812

913
import Foundation

Sources/SwiftDate/DateInRegion/DateInRegion+Compare.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//
2-
// DateInRegion+Compare.swift
32
// SwiftDate
3+
// Parse, validate, manipulate, and display dates, time and timezones in Swift
44
//
5-
// Created by Daniele Margutti on 07/06/2018.
6-
// Copyright © 2018 SwiftDate. All rights reserved.
5+
// Created by Daniele Margutti
6+
// - Web: https://www.danielemargutti.com
7+
// - Twitter: https://twitter.com/danielemargutti
8+
// - Mail: hello@danielemargutti.com
9+
//
10+
// Copyright © 2019 Daniele Margutti. Licensed under MIT License.
711
//
812

913
import Foundation

0 commit comments

Comments
 (0)