From 1b4ef20d192f2081c3b54df1d9d66832b96a3a04 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sun, 20 Oct 2013 21:16:07 -0700 Subject: [PATCH] Added 'days' to playlist total time, but only if the total hours is 24 or greater --- Playlist/PlaylistController.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 94181b2ab..7a9a2c470 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -150,16 +150,23 @@ { double tt = 0; ldiv_t hoursAndMinutes; + ldiv_t daysAndHours; for (PlaylistEntry *pe in [self arrangedObjects]) { if (!isnan([pe.length doubleValue])) tt += [pe.length doubleValue]; } - int sec = (int)(tt); + long sec = (long)(tt); hoursAndMinutes = ldiv(sec/60, 60); - [self setTotalTime:[NSString stringWithFormat:@"%ld hours %ld minutes %d seconds", hoursAndMinutes.quot, hoursAndMinutes.rem, sec%60]]; + if ( hoursAndMinutes.quot >= 24 ) + { + daysAndHours = ldiv(hoursAndMinutes.quot, 24); + [self setTotalTime:[NSString stringWithFormat:@"%ld days %ld hours %ld minutes %ld seconds", daysAndHours.quot, daysAndHours.rem, hoursAndMinutes.rem, sec%60]]; + } + else + [self setTotalTime:[NSString stringWithFormat:@"%ld hours %ld minutes %ld seconds", hoursAndMinutes.quot, hoursAndMinutes.rem, sec%60]]; } - (void)tableView:(NSTableView *)tableView