Question

Y a-t-il un moyen d'obtenir Calendarweek d'un NSDate selon ISO 8601. Je pense:

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

utilise un algorithme différent.

ISO Définition: CW1 est la première semaine de l'année contenant 4 jours, CW commence le lundi

Était-ce utile?

La solution

J'ai découvert. Il est possible de configurer le NSCalender:

[cal setFirstWeekday:2];            //week starts on Monday
[cal setMinimumDaysInFirstWeek:4];  //first week in the year containing 4 day

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top