+ (BOOL)isSameDayForDate:(NSDate *)date1 andDate:(NSDate*)date2
{
if (nil == date1 || nil == date2)
{
return NO;
}
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSEraCalendarUnit |NSYearCalendarUnit | NSMonthCalendarUnit | NSMonthCalendarUnit |NSDayCalendarUnit) fromDate:date1];
NSDate *OneDate = [calendar dateFromComponents:components];
components = [calendar components:(NSEraCalendarUnit |NSYearCalendarUnit | NSMonthCalendarUnit | NSMonthCalendarUnit |NSDayCalendarUnit) fromDate:date2];
NSDate *OtherDate = [calendar dateFromComponents:components];
return ([OneDate isEqualToDate:OtherDate]);
}