import net.pterodactylus.xdcc.data.Download;
import com.google.common.base.Joiner;
+import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.Subscribe;
return String.format("%dB", number);
}
+ /**
+ * Formats the given number of seconds into a more easily readable string.
+ *
+ * @param seconds
+ * The number of seconds
+ * @return The formatted time, or “unknown” if the time is unknown
+ */
+ static String t(Optional<Long> seconds) {
+ if (!seconds.isPresent()) {
+ return "unknown";
+ }
+ if (seconds.get() > 3600) {
+ return String.format("%02d:%02d:%02d", seconds.get() / 3600, (seconds.get() / 60) % 60, seconds.get() % 60);
+ }
+ return String.format("%02d:%02d", (seconds.get() / 60) % 60, seconds.get() % 60);
+ }
+
}