Skip to content

Commit 8e9c451

Browse files
[#57] Fix progress_done
1 parent 9aa2536 commit 8e9c451

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/libhrmp/playback.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,16 +526,32 @@ print_progress_done(struct playback* pb)
526526
if (!config->quiet)
527527
{
528528
char t[MAX_PATH];
529+
int total_hour = 0;
529530
int total_min = 0;
530531
int total_sec = 0;
531532

532533
memset(&t[0], 0, sizeof(t));
533534

534535
total_min = (int)(pb->fm->duration) / 60;
535-
total_sec = pb->fm->duration - (total_min * 60);
536536

537-
snprintf(&t[0], sizeof(t), "%d:%02d/%d:%02d", total_min, total_sec,
538-
total_min, total_sec);
537+
if (total_min >= 60)
538+
{
539+
total_hour = (int)(total_min / 60.0);
540+
total_min = total_min - (total_hour * 60);
541+
}
542+
543+
total_sec = pb->fm->duration - ((total_hour * 60 * 60) + (total_min * 60));
544+
545+
if (total_hour > 0)
546+
{
547+
snprintf(&t[0], sizeof(t), "%d:%02d:%02d/%d:%02d:%02d",
548+
total_hour, total_min, total_sec,
549+
total_hour, total_min, total_sec);
550+
}
551+
else
552+
{
553+
snprintf(&t[0], sizeof(t), "%d:%02d/%d:%02d", total_min, total_sec, total_min, total_sec);
554+
}
539555

540556
printf("\r[%d/%d] %s: %s %s (%s) (100%%)\n", pb->file_number, pb->total_number,
541557
config->devices[pb->device].name, pb->fm->name, pb->identifier,

0 commit comments

Comments
 (0)