Commit 1679ed33 authored by Marvin Scholz's avatar Marvin Scholz

macosx: Fix playlist duration calculation

Manual backport of a99d9803, to remain
compatible with macOS < 10.10.

Fix #19221
Signed-off-by: Marvin Scholz's avatarMarvin Scholz <epirat07@gmail.com>
parent 199747d9
......@@ -882,16 +882,19 @@ static const float f_min_window_height = 307.;
mt_duration = mt_duration / 1000000;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:mt_duration];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
if (mt_duration >= 86400) {
[formatter setDateFormat:@"dd:HH:mm:ss"];
int sec = (mt_duration % 60);
int min = (mt_duration % 3600) / 60;
int hours = (mt_duration % 86400) / 3600;
int days = (int)(mt_duration / 86400);
NSString *result;
if (days > 0) {
result = [NSString stringWithFormat:@"%i:%i:%02i:%02i", days, hours, min, sec];
} else {
[formatter setDateFormat:@"HH:mm:ss"];
result = [NSString stringWithFormat:@"%i:%02i:%02i", hours, min, sec];
}
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
return [NSString stringWithFormat:@" — %@",[formatter stringFromDate:date]];
return [NSString stringWithFormat:@" — %@", result];
}
- (IBAction)searchItem:(id)sender
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment