I am using this code to get the number of day in the current week:
static func currentDayOfWeek() -> Int {
let comp = NSCalendar.current.dateComponents([.weekday], from: Date())
if comp.weekday == 1 {
return 7
}
return comp.weekday! - 1
}
Monday = 1
Tuesday = 2
...........
Sunday = 7
I can't manage to figure out how to get the current day number of the month and year.
For example for today current day number for the month should be 3
and for the year it should be 277
.
Any suggestions ?