NSDateComponents weekOfYear returns wrong value

后端 未结 1 640
一生所求
一生所求 2021-01-22 01:48
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierISO8601];
[calendar setTimeZone:[NSTimeZone defaultTimeZone]];
[calendar setFir         


        
相关标签:
1条回答
  • 2021-01-22 02:12

    Your minimumDaysInFirstWeek is 1. That means that any week that has at least 1 day in the new year is the 1st week of that year. Docs

    According to ISO:

    There are mutually equivalent descriptions of week 01:

    the week with the year's first Thursday in it (the formal ISO definition), the week with 4 January in it, the first week with the majority (four or more) of its days in the starting year, and the week starting with the Monday in the period 29 December – 4 January.

    0 讨论(0)
提交回复
热议问题