Improve SecondsFormatter readability.

This commit is contained in:
Jan Weiß 2021-05-06 14:07:19 +02:00
parent 1e6aa2975f
commit a3398a1f07

View file

@ -29,14 +29,14 @@
return nil; return nil;
} }
double floatValue = [object doubleValue]; NSTimeInterval timeInterval = [object doubleValue];
if (isnan(floatValue)) { return @"NaN"; } if (isnan(timeInterval)) { return @"NaN"; }
if (isinf(floatValue)) { return @"Inf"; } if (isinf(timeInterval)) { return @"Inf"; }
BOOL isNegative = signbit(floatValue); BOOL isNegative = signbit(timeInterval);
int totalSeconds = (int)(isNegative ? -floatValue : floatValue); int totalSeconds = (int)(isNegative ? -timeInterval : timeInterval);
int seconds = totalSeconds % 60; int seconds = totalSeconds % 60;
int minutes = totalSeconds / 60; int minutes = totalSeconds / 60;