This file contains hidden or 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
| extension BidirectionalCollection where Iterator.Element == String, SubSequence.Iterator.Element == String { | |
| var sentence: String { | |
| guard let last = last else { return "" } | |
| return count <= 2 ? joined(separator: " and ") : | |
| dropLast().joined(separator: ", ") + " and " + last | |
| } | |
| } |
This file contains hidden or 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
| extension Date { | |
| var year: Int { return Calendar.autoupdatingCurrent.component(.year, from: self) } | |
| var month: Int { return Calendar.autoupdatingCurrent.component(.month, from: self) } | |
| var day: Int { return Calendar.autoupdatingCurrent.component(.day, from: self) } | |
| var firstDayOfMonth: Date { | |
| return Calendar.autoupdatingCurrent.date(from: DateComponents(year: year, month: month, day: 1))! | |
| } | |
| var lastDayOfMonth: Date { | |
| return Calendar.autoupdatingCurrent.date(from: DateComponents(year: year, month: month+1, day: 0))! | |
| } |
NewerOlder