I am trying to get a date from the component
's year
, week
, and dayOfWeek
, but I am getting weird dates from the above mentioned function. Here is what I do:
let calendar = NSCalendar(identifier: NSCalendarIdentifierISO8601)
let components = NSDateComponents()
components.weekday = 1
components.weekOfYear = 16
components.yearForWeekOfYear = 2016
let dateKW = calendar?.dateFromComponents(components)
The variable dateKW equals 24. April 2016. When I change the weekday
to 2, I get 18. April 2016. Why is that the case? Shouldn't the first day be 17. April 2016?