aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-29 17:24:49 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-29 17:24:49 +0530
commit38ebdf9283dbe4cae7d128e8800b589c7140ba7b (patch)
tree3b5abb6573ba67d5aa6c0c918b326abbd75639f8 /src/app.rs
parent11d64728748ee5091de9695c0717599368f5103b (diff)
get rid of humantime crate
Diffstat (limited to 'src/app.rs')
-rwxr-xr-xsrc/app.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/app.rs b/src/app.rs
index c2ce06c..e38222d 100755
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,3 +1,5 @@
+use std::time::Duration;
+
use crate::browser::FileBrowser;
use crate::connection::Connection;
use crate::list::ContentList;
@@ -152,7 +154,9 @@ impl App {
for (i, song) in self.queue_list.list.clone().iter().enumerate() {
if song.contains(&file) {
self.conn.conn.delete(i as u32).unwrap();
- if self.queue_list.index == self.queue_list.list.len() - 1 && self.queue_list.index != 0 {
+ if self.queue_list.index == self.queue_list.list.len() - 1
+ && self.queue_list.index != 0
+ {
self.queue_list.index -= 1;
}
}
@@ -268,4 +272,17 @@ impl App {
pub fn reset_cursor(&mut self) {
self.cursor_position = 0;
}
+
+ /// Given time in seconds, convert it to hh:mm:ss
+ pub fn format_time(time: Duration) -> String {
+ let time = time.as_secs();
+ let h = time / 3600;
+ let m = (time % 3600) / 60;
+ let s = (time % 3600) % 60;
+ if h == 0 {
+ format!("{:02}:{:02}", m, s)
+ } else {
+ format!("{:02}:{:02}:{:02}", h, m, s)
+ }
+ }
}