+static void eta_to_str(char *str, int eta_sec)
+{
+ unsigned int d, h, m, s;
+ static int always_d, always_h;
+
+ d = h = m = s = 0;
+
+ s = eta_sec % 60;
+ eta_sec /= 60;
+ m = eta_sec % 60;
+ eta_sec /= 60;
+ h = eta_sec % 24;
+ eta_sec /= 24;
+ d = eta_sec;
+
+ if (d || always_d) {
+ always_d = 1;
+ str += sprintf(str, "%02dd:", d);
+ }
+ if (h || always_h) {
+ always_h = 1;
+ str += sprintf(str, "%02dh:", h);
+ }
+
+ str += sprintf(str, "%02dm:", m);
+ str += sprintf(str, "%02ds", s);
+}
+