[vlc-commits] macosx: Use NSDateComponentsFormatter for playlist duration
Marvin Scholz
git at videolan.org
Mon Dec 4 15:16:50 CET 2017
vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Mon Dec 4 15:16:22 2017 +0100| [a99d9803133eafd8789a4fc4bbd30b0de0bb53f6] | committer: Marvin Scholz
macosx: Use NSDateComponentsFormatter for playlist duration
This should fix a bug with off-by-one days calculation.
Fix #19221
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a99d9803133eafd8789a4fc4bbd30b0de0bb53f6
---
modules/gui/macosx/VLCMainWindow.m | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index 1b10437f7b..f6d2385d44 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -882,16 +882,12 @@ 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"];
- } else {
- [formatter setDateFormat:@"HH:mm:ss"];
- }
- [formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
+ NSDateComponentsFormatter *formatter = [[NSDateComponentsFormatter alloc] init];
+ formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleAbbreviated;
+
+ NSString* outputString = [formatter stringFromTimeInterval:mt_duration];
- return [NSString stringWithFormat:@" — %@",[formatter stringFromDate:date]];
+ return [NSString stringWithFormat:@" — %@", outputString];
}
- (IBAction)searchItem:(id)sender
More information about the vlc-commits
mailing list