I want to compare different times of outlets with ipad current time so what i did was this 

```
if(CT!=nil && startTime!=nil &&endTime!=nil)
{

    /* If current time is greater than begin time but less than end time then he can give feedack
     */
    if (([CT compare:startTime]== NSOrderedDescending) && ([CT compare:endTime]== NSOrderedAscending) ) {

        return YES;
    }

    else if (([CT compare:startTime]== NSOrderedSame) || ([CT compare:endTime]== NSOrderedSame))
    {
         return YES;
    }
    else if (([CT compare:startTime]== NSOrderedDescending) && ([CT compare:endTime]== NSOrderedDescending))
    {
        return NO; // out of outlet timings
    }

```

This seems to be working good till now but when i change the outlet time to

start time = 18:30PM 
end time = 2:00 AM

Then in that case the above code fails, when the ipad clocks at 1:00AM then the first if condition fails so i added this code below

```
 if (([CT compare:startTime]== NSOrderedAscending) && ([CT compare:endTime]== NSOrderedAscending))
    {

    }

```

Now as a developer i am sure that if the device clocks at 1:00 AM then it wont fail but what if somebody updated the outlet timing to

start time = 9:00AM 
end time = 11:00 AM

and current device time = 8:00 AM 

then in the above case my the second code will fail.

what i want is some suggestion as in what i can do in the second if condition

Code that creates CT is :

```
 NSDate *sysDate = [NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"HH:mm:ss"];
NSString *timeString = [df stringFromDate:sysDate];
NSDate *CT = [df dateFromString:timeString];

```

startTime and endTime are date objects stored in the plist.