Created
November 30, 2016 13:09
-
-
Save malcommac/14ad049a5acaee53c33e145cccc25f82 to your computer and use it in GitHub Desktop.
Enumerate Dates in SwiftDate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using DateInRegion | |
// create an array of [DateInRegion] instances from fromDate (included) to toDate (30 days ahead) by incrementing each date by 1 day | |
let fromDate = DateInRegion().startOf(component: .day) // normalize at the start of the day | |
let toDate = fromDate + 30.days | |
let dates = DateInRegion.dates(between: fromDate, and: toDate, increment: 1.day) | |
// using Date | |
// create an array of [DateInRegion] instances from fromDate (included) to toDate (30 days ahead) by incrementing each date by 1 day,2 hours and 40 minutes | |
let fromDate = Date().startOf(component: .day) // normalize at the start of the day | |
let toDate = fromDate + 30.days | |
let dates = Date.dates(between: fromDate, and: toDate, increment: (1.day && 2.hours && 40.minutes) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment