Events list to check that the given event is the first event of the month iOS swift
Problem:
I'm having one event with me and i had array of events.I want to check that event was the first event in the month.How to achieve that?
Solution:
// MARK: - get is first in month
func IsFirstEventInMonth(currentEve
let filtered = items.filter { ($0.date ?? Date()).isInSameMonth(as: currentEvent.date ?? Date()) }
if filtered.count>0 {
return filtered[0].dateEvent == currentEvent.date
}
return false
}
I'm having one vent with me and array of events.Above function will be used to check that the list in the array for first event of the month that i had given as input.
Comments
Post a Comment