NSTimeInterval compTime = [compTimeValue timeIntervalSince1970];
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval diff = compTime - [now timeIntervalSince1970];
-
- NSTimeInterval repairTime = diff + 20 * 60;
- repairTime = repairTime > 0 ? repairTime : 0;
- return @(repairTime);
+ return @(diff + 20 * 60);
}
@end
NSLog(@"obj class is %@", NSStringFromClass([obj class]));
return @"";
}
+
+ BOOL minus = timeInterval < 0;
+ if(minus) timeInterval *= -1;
NSInteger hour = timeInterval / (60 * 60);
timeInterval -= hour * 60 * 60;
timeInterval -= minutes * 60;
NSInteger seconds = timeInterval;
- return [NSString stringWithFormat:@"%02ld:%02ld:%02ld", hour, minutes, seconds];
+ return [NSString stringWithFormat:@"%s%02ld:%02ld:%02ld", minus ? "-" : "", hour, minutes, seconds];
}
@end