[vlc-commits] macosx: Fix playlist duration calculation
Marvin Scholz
git at videolan.org
Tue Dec 5 18:24:48 CET 2017
vlc/vlc-3.0 | branch: master | Marvin Scholz <epirat07 at gmail.com> | Tue Dec 5 18:19:49 2017 +0100| [1679ed33d3415ea61d38da24412d16335b084846] | committer: Marvin Scholz
macosx: Fix playlist duration calculation
Manual backport of a99d9803133eafd8789a4fc4bbd30b0de0bb53f6, to remain
compatible with macOS < 10.10.
Fix #19221
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=1679ed33d3415ea61d38da24412d16335b084846
---
modules/gui/macosx/VLCMainWindow.m | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index 1b10437f7b..996aa3a6e8 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -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
More information about the vlc-commits
mailing list