0
是否有辦法獲得當年第一季度的第一個日期?我已經知道如何獲得周,月,年的當天......我用這個代碼:獲取當前季度的第一天
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* comps = [calendar components:
NSCalendarUnitYearForWeekOfYear |
NSCalendarUnitYear|
NSCalendarUnitMonth|
NSCalendarUnitWeekOfMonth|
NSCalendarUnitWeekday
fromDate:[NSDate date]];
[comps setWeekday:2]; // 2: monday
NSDate * firstDayOfTheWeek = [calendar dateFromComponents:comps];
[comps setWeekday:1]; // 1: Sunday
NSDate *lastDayOfTheWeek = [calendar dateFromComponents:comps];
[comps setDay:1];
NSDate * firstDayOfTheMonth = [calendar dateFromComponents:comps];