- (void)getSelectDate:(NSString *)day horse:(NSString *)horse minute:(NSString *)minute{
MYLog(@"%@,%@,%@",day,horse,minute);
//获取这个月的天数
NSDate *today = [NSDate date];
NSCalendar *c = [NSCalendar currentCalendar];
NSRange days = [c rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:today];
NSLog(@"%lu,%lu",(unsigned long)days.length,(unsigned long)days.location);
//获取当前时间
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd-HH-mm"];
NSString *currentOlderOneDateStr = [dateFormatter stringFromDate:today];
MYLog(@"%@",currentOlderOneDateStr);
NSArray *time = [currentOlderOneDateStr componentsSeparatedByString:@"-"];
//获取时间控件
NSIndexPath *path = [NSIndexPath indexPathForRow:1 inSection:0];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:path];
if ([day isEqualToString:@"今天"]) {
//判断小时
if ([horse integerValue] <[time[3] integerValue]) {
[self showToastHUDView:@"请选择对的日期" afterDelay:2];
cell.detailTextLabel.text = @"";
return;
}else if ([horse integerValue] == [time[3] integerValue] ) {
if ([time[4] integerValue]<30 && ([time[4] integerValue]+30)<=[minute integerValue]) {
MYLog(@"%@,%@",time[4],minute);
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%@-%@ %@:%@",time[0],time[1],time[2],horse,minute];
}else{
MYLog(@"%@,%@",time[4],minute);
[self showToastHUDView:@"时间间隔太短" afterDelay:2];
cell.detailTextLabel.text = @"";
return;
}
}else{
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%@-%@ %@:%@",time[0],time[1],time[2],horse,minute];
}
}else if([day isEqualToString:@"明天"]){
//判断年月日是否有进位
NSInteger nextDay = [time[2] integerValue];
NSInteger nextMoth = [time[1] integerValue];
if (day.length < nextDay+1) {
NSInteger nextAddOne = nextMoth +1;
if (nextAddOne>12) {
NSInteger years = [time[0] integerValue];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld-%@-%@ %@:%@",(years+1),@"1",@"1",horse,minute];
}else{
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%ld-%@ %@:%@",time[0],(long)nextAddOne,@"1",horse,minute];
}
}else{
NSInteger day =[time[2] integerValue];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%@-%ld %@:%@",time[0],time[1],(day+1),horse,minute];
}
}else if([day isEqualToString:@"后天"]){
//判断年月日是否有进位
NSInteger nextDay = [time[2] integerValue];
NSInteger nextMoth = [time[1] integerValue];
if ((day.length < nextDay+2)&&day.length != nextDay) {
NSInteger nextAddOne = nextMoth +1;
if (nextAddOne>12) {
NSInteger years = [time[0] integerValue];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld-%@-%@ %@:%@",(years+1),@"1",@"1",horse,minute];
}else{
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%ld-%@ %@:%@",time[0],(long)nextAddOne,@"1",horse,minute];
}
}else{
NSInteger day =[time[2] integerValue];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%@-%ld %@:%@",time[0],time[1],(day+2),horse,minute];
}
if ((day.length < nextDay+2)&&day.length == nextDay) {
NSInteger nextAddOne = nextMoth +1;
if (nextAddOne>12) {
NSInteger years = [time[0] integerValue];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld-%@-%@ %@:%@",(years+1),@"1",@"2",horse,minute];
}else{
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%ld-%@ %@:%@",time[0],(long)nextAddOne,@"2",horse,minute];
}
}else{
NSInteger day =[time[2] integerValue];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@-%@-%ld %@:%@",time[0],time[1],(day+2),horse,minute];
}
}
}