I have the variable fecha
that when doing print
shows per console: 2016-11-20 23:00:00 +0000
The problem is that when you do this:
let auxCalendar = calendar.dateComponents([.weekday, .day, .weekdayOrdinal, .month], from: fecha)
print("*\(fecha)*")
print("\n***\n\(auxCalendar)\n\(fecha)\n***\n")
Show me this:
* 2016-11-20 23:00:00 +0000 *
***
month: 11 day: 21 weekday: 2 weekdayOrdinal: 3 isLeapMonth: false
2016-11-20 23:00:00 +0000
***
As you can see there is an incongruity, because I have passed the date with day 20 and he returns me on the 21st day
The variable calendar
is initialized like this:
var calendar = Calendar(identifier: .gregorian)
calendar.locale = Locale(identifier: "es_ES")