return width + 6;
}
-static void get_duration_buf(int seconds, char *buf, short unsigned max_width)
+static void get_duration_buf(int seconds, char *buf, struct ls_options *opts)
{
unsigned hours = seconds / 3600, mins = (seconds % 3600) / 60;
+ short unsigned max_width;
- if (!hours) /* m:ss or mm:ss */
+ if (!hours) { /* m:ss or mm:ss */
+ max_width = opts->mode == LS_MODE_LONG?
+ opts->widths.duration_width : 4;
sprintf(buf, "%*u:%02u", max_width - 3, mins, seconds % 60);
- else /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */
+ } else { /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */
+ max_width = opts->mode == LS_MODE_LONG?
+ opts->widths.duration_width : 7;
sprintf(buf, "%*u:%02u:%02u", max_width - 6, hours, mins,
seconds % 60);
+ }
}
static char *make_attribute_lines(const char *att_bitmap, struct afs_info *afsi)
sizeof(last_played_time), current_time, opts->mode);
if (ret < 0)
return ret;
- get_duration_buf(afhi->seconds_total, duration_buf, w->duration_width);
+ get_duration_buf(afhi->seconds_total, duration_buf, opts);
if (have_score) {
if (opts->mode == LS_MODE_LONG)
sprintf(score_buf, "%*li ", w->score_width, d->score);