Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSInteger)getEducationWeekFromDate:(NSDate *)date{
- NSCalendar *calendar = [NSCalendar currentCalendar];
- NSDateComponents *components = [[NSDateComponents alloc]init];
- components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit| NSMinuteCalendarUnit) fromDate:date];
- components.day = components.day - [self weekDayFromDay:date];
- components.hour = 0;
- components.minute = 0;
- date = [calendar dateFromComponents:components];
- NSDate *timeTableStartDate = self.startDate;
- components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit| NSMinuteCalendarUnit) fromDate:timeTableStartDate];
- components.day = components.day - [self weekDayFromDay:timeTableStartDate];
- components.hour = 0;
- components.minute = 0;
- timeTableStartDate = [calendar dateFromComponents:components];
- NSInteger weeks = [[calendar components:NSWeekCalendarUnit fromDate:timeTableStartDate toDate:date options:0]week] + 1;
- return weeks;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement