I want to get weekofYear with date \'2014-12-31\' ,but it always return 1 not 52 here is my code:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSUIntege
IF the week is 1 (first days of 2015 or last few days of 2014)
AND the day is greater than 20 (so it's one of the last three days of 2014)
THEN (calculate the week of your date minus 5 days, and add 1).
This will make the last few days of the year into their own week, which is sometimes week 52, sometimes week 53. And it works with European and US calendars.
You'll need to think what you want to do if Jan 1st is in the last week of the previous year. Might make it week 0. So really going with the standard and accepting what iOS tells you is the saner way to do it.