Reputation: 4736
How can I find out the Date of Monday if I pass the week number. For example, I need the Monday of the Week 24 of the year
Upvotes: 0
Views: 1074
Reputation:
Fill out a NSDateComponents
object with the information you have. Then you can ask the current NSCalendar
what date corresponds to those components.
NSDateComponents *components = [NSDateComponents new];
components.weekday = 2;
components.weekOfYear = 24;
components.year = 2012;
NSDate *date = [[NSCalendar currentCalendar] dateFromComponents: components];
The weekday
property starts with Sunday = 1.
If you are on OS X 10.7 or newer you should use the property yearForWeekOfYear
instead of year
.
Upvotes: 2