Question

is there a way to get calendarweek of an NSDate according ISO 8601. I think:

Datecomponents *dateComponents = [cal components:(NSWeekOfYearCalendarUnit ) fromDate: testDate ];
int calandarWeek =  [dateComponents weekOfYear];

uses a different algorithm.

ISO definition: CW1 is the first week in the year containing 4 day, CW start on Mondays

Was it helpful?

Solution

I found out. It´s possible to configure the NSCalender:

[cal setFirstWeekday:2];            //week starts on Monday
[cal setMinimumDaysInFirstWeek:4];  //first week in the year containing 4 day
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top