当前日期不应早于开始日期和结束日期,但它可以等于开始日期或结束日期。
我应该如何修改代码?
for(AllBookings *book in bookarray)
{
NSString *startdte = book.StartDate; //taking start date from array
NSString *enddte = book.EndDate;
NSDate *start = [self getDateFromJSON:startdte];
NSDate *end = [self getDateFromJSON:enddte];
NSDate *now = [NSDate date];
NSTimeInterval fromTime = [start timeIntervalSinceReferenceDate];
NSTimeInterval toTime = [end timeIntervalSinceReferenceDate];
NSTimeInterval currTime = [[NSDate date] timeIntervalSinceReferenceDate];
if((fromTime<currTime) && (toTime>=currTime))//checking if currnt is in btw strt n end
{
success = TRUE;
break;
}
else {
success = FALSE;
}
}